File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How do I find the page where i am coming from in my current jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How do I find the page where i am coming from in my current jsp page" Watch "How do I find the page where i am coming from in my current jsp page" New topic
Author

How do I find the page where i am coming from in my current jsp page

jaya raj
Greenhorn

Joined: Mar 12, 2004
Posts: 2
Hi,

How do I find the page where i am coming from in my current jsp page.
I have a page called registration.jsp where I would have to find whether I had from login page or some other link.
Please help me with this
Thank you
Mike Firkser
Ranch Hand

Joined: Oct 21, 2003
Posts: 247

You may want to try


Mike Firkser
Rutgers '84
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by jaya raj:
Hi,

How do I find the page where i am coming from in my current jsp page.
I have a page called registration.jsp where I would have to find whether I had from login page or some other link.
Please help me with this
Thank you

It depends on how you get there. If you get to the page through a forward, there are request attributes (in Servlet 2.4/JSP 2.0) that hold URI information for the original request; if it's through an include, the request object still holds the original URI info; if it's through a redirect, the original info is typically lost (there's an HTTP header that may contain the info, but not always).
Your best bet is to let whatever gets you to the page include its URI in a request parameter (if its a redirect) or a request attribute (if it's a forward/include) and read the info from there in the registration.jsp file. That's what I do in the examples of a similar scenario in my book.


Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I don't have my code handy.
But, where i come from; we look at the system stack and go back by 1 level in the stack. Could be the stack traversal is framework proprietary to my company thought. But that is just a suggestion.
Kishore.


Kishore
SCJP, blog
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I've once implemented a sorta callstack in JSP as well to keep track of where the user came from.
Enables those nice dynamic tracking links on a page showing where you've been the last X pages (which is in part why it was needed).


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I find the page where i am coming from in my current jsp page