LoginSignup
1
1

More than 5 years have passed since last update.

Javaでリダイレクト元のURLを取得する時に使用したソース

Last updated at Posted at 2016-12-27

はじめに

OGPで設定するURL項目をフィールドに渡す時、
意図しない値を表示していた。
その時の調査に用いたソースです。

Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
  System.out.print.ln(headerNames.nextElement());
}
Enumeration<String> attributeNames = request.getAttributeNames();
while (attributeNames.hasMoreElements()) {
  System.out.print.ln(attributeNames.nextElement());
}

苦労したこと

普段はrequest.getHeaderNames() を多用しているのですが、今回は全く関係していませんでした。
request.getAttribute("javax.servlet.forward.request_uri");
結論として上記値で取得することができました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1