• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 249
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to try
 
Author
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!