Getting the URL of the calling Java page

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

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

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

+7
source share
2 answers

This will give you a link (in most cases)

 request.getHeader("referer"); 

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

And here for more details about the request API

+9
source

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

One way is to set the cookie on http: // localhost / display and disable it on http: // localhost / save . Thus, you need to know if the user visited the display before saving.

+2
source

All Articles