This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Original Servlet Name after a Forward to a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Original Servlet Name after a Forward to a jsp" Watch "Original Servlet Name after a Forward to a jsp" New topic

Original Servlet Name after a Forward to a jsp

sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
I am sure there is an answer to this one but i have not been able to find out.
I have a servlet registered as xxx from which i forward to some jsp page /yyy/zzz.jsp
How can i get the original xxx Servlet name in the zzz.jsp
I have tried the Referer in the header, the request URI, the Servlet name in the request and the Path Info. None of these have worked as all return /yyy/zzz.jsp
Any Help will be greatly appreciated

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12683
Maybe you should attach the servlet name to the request with setAttribute before forwarding so the JSP can get it later.
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
it shouldn't matter which servlet they came from the jsps point of view. Jsp shouldn't handle conditional logic, or if it does, it should be limited to just presentation as much as possible.
Having said that, you could use request.getRequestURL() (see the javadoc for HttpServletRequest).

comp.lang.javascript FAQ:
I agree. Here's the link:
subject: Original Servlet Name after a Forward to a jsp
Similar Threads
Different INPUT.jsp in DispatchAction
call a servlet from a jsp????
installing multiple instance of tomcat
mysql & incomplete insertions!
getting the value from <bean:write> tag