Reputation: 1884
I've a URL pattern like webroot/TellSomeoneMail
and corresponding class,
<servlet>
<servlet-name>TellSomeoneMail</servlet-name>
<display-name>Tell Someone Mail</display-name>
<servlet-class>com.nightingale.register.servlet.TellSomeoneMailServlet</servlet-class>
</servlet>
but how to identify which JSP file calling this servlet?
Upvotes: 1
Views: 5732
Reputation: 7779
You can identify during execution into our servlet by looking to the referer header in the HTTP body:
String referrer = request.getHeader("referer");
Edit 1: You can also use session to keep the last url acceded by the user (such mechanism is already present in framework like grails or Spring under the "flash" attribute, not to be confused with adobe flash). If you use simple Servlet / JSP, you need to code such support...
Edit 2 Last solution if cookie and referee is blocked, is to add a parameter in the URL with reference to the last page, for instance URL?from=home_pg
or URL?from=/homepage.html
but it could require rewriting of urls embedded in the page.
Upvotes: 3
Reputation: 17487
To find JSP pages that allow the user to make requests to your servlet : Check the path the servlet is mapped under in the <servlet-mapping>
element(s) in web.xml.
Then do a full text search on all the JSP's in your projet for this string. Look for HTML <a>
and <form>
element with target containing your servlet path.
Upvotes: 0
Reputation: 5758
you can get the URL from which the request was sent. Take a look at the following code
if (request instanceof HttpServletRequest) {
String url = ((HttpServletRequest)request).getRequestURL().toString();
}
Upvotes: 0