How do i know from which page the request has come from?

cedric chin

[I have a JSP which can be called from multiple pages . On exiting from the page it must go back to the particular page from where it was requested.How do i know the URL of the calling page?]

Try this:

String refererPage = request.getHeader("referer");
[Tim Delesio adds:
You can also create a hidden field in the form and then use a if statement to check and route accordingly.
Or, if the parameter you've added is called 'original',
response.sendRedirect( request.getParameter("original") );