7

To put you in the picture, we're using a custom server based on Tomcat 6.0.29. We're developing using Java and Spring.

Let's say I have a link which takes you from http://localhost/display to http://localhost/save. In the controller of http://localhost/save, can I get http://localhost/display from the request parameter somehow?

request.getRequestURL() seems to get the url of the current page.

Eran Medan
  • 44,555
  • 61
  • 184
  • 276
Krt_Malta
  • 9,265
  • 18
  • 53
  • 91

2 Answers2

10

This should give you the referring page (is most cases)

request.getHeader("referer"); 

See here for details http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z14

And here for more details on the request API

Eran Medan
  • 44,555
  • 61
  • 184
  • 276
2

You can use "referrer" header to check the page from where the request was made. However it would not work in all cases.

One way could be to set a cookie on http://localhost/display and unset it on http://localhost/save. That way you would know if user visited display prior to save.

Shamit Verma
  • 3,839
  • 23
  • 22