• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletRequest - get previous page url

 
Brian Hsu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpServletRequest has methods to get the current page's URL. Is it possible to get the previous like Apache log's referrer? Thanks.
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, except the name of the HTTP header you're looking for is "Referer" (not spelled the way you might expect). You can get header values from the request.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64719
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that it is not guaranteed to be set, or to be set correctly.

Why do you need this? If you are trying to make decisions regarding what to do based on where you came from... don't!

 
Brian Hsu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Be aware that it is not guaranteed to be set, or to be set correctly.

Why do you need this? If you are trying to make decisions regarding what to do based on where you came from... don't!



I'm trying to use this for debugging. Currently I'm getting lots of error notification emails from an URL and I'd like to find out where/how users got to that page from.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64719
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, ok. I was hoping it wasn't something along the lines of what was being discussed here.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64719
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For debugging, you should also be able to use tools such as HttpFox to observe the headers without having to change any code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic