It's not a secret anymore!*
The moose likes JSP and the fly likes is it possible to find out which servlet forwarded request to a JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "is it possible to find out which servlet forwarded request to a JSP page" Watch "is it possible to find out which servlet forwarded request to a JSP page" New topic
Author

is it possible to find out which servlet forwarded request to a JSP page

Alan Ford
Ranch Hand

Joined: Oct 26, 2003
Posts: 107
is it possible to find out which servlet forwarded request to a JSP page, from that JSP page.
(I realize that solution with passing a paramenter would work)


TNT<br />MCP, SCJP 1.4,
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
I think you should be able to pull that information from the Referer header of the request, try:
request.getHeader("Referer");
It should give you the URL that you just came from (e.g. your servlet). Depending on what you are doing with it, you may have to parse the string or check only the last part of it.
Hope this helps.


- Chris Stehno, SCPJ
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Referer won't necessarily identify the forwarding servlet; it will report what the brwser decided to put into the header. Especially if the request has been forwarded around a bit, this may or may not be useful.
My question is: why would you want to do this? Passing info forward (via attributes) is a much more conventional and architecturally pure mechanism. Back-tracking in order to affect behavior muddies the architectural picture and introduces coupling where none is needed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is it possible to find out which servlet forwarded request to a JSP page
 
Similar Threads
Scope of implicit response object
tomcat 5 and error page
How many ways we can call Static HTML page from Servlet
c:set and scope
Attributes sent from JSP wont show in Servlet