TomRed.net

  • Increase font size
  • Default font size
  • Decrease font size
Subscribe Bookmark and Share
Home Tutorials Java Java Servlet how to get JSP referrer file name within a servlet or JSP

Java Servlet how to get JSP referrer file name within a servlet or JSP

PDF
User Rating: / 2
PoorBest 

There is often reason to find out which JSP called the servlet or JSP that is running. The file that directed the browser or client to the running servlet or JSP is called to as the referrer.

Your reason may be for security or authentication reason. You may have a servlet that can only be accessed by a particular JSP. If this is the case then you can quickly find out which JSP has forwarded to the servlet or JSP using

  1. request.getHeader("Referer");
 

this is set by the browser in the request so you do not need to set it. Note: the incorrect spelling of Referer in the getHeader this is intentional and is an artefact of an initial error in the definition and has remained since.