• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to know the last page visited?

 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a jsp page know as to which page is the user coming from. As in, suppose, there is a jsp page abc.jsp and its got a link on def.html and ghi.html. Now how can it determine whether it was requested from def or ghi?

thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35744
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shashank,
The referring page is in one of the HTTP headers:
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton Jeanne.
 
Junilu Lacar
Sheriff
Posts: 10061
120
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure this will work in all cases, since there are conditions when a client is not supposed to send the referer header. Also, if your URI is hitting a servlet or if you're using a framework such as Struts, the JSP URI is obscured and I doubt the referer header will be of any use.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a history of visited pages to the session.
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i tried using request.getHeader("Referer"). However, i face an problem with it. Let suppose the page calling abc.jsp was http://localhost:8080/jsp/def.html then it returns only http://localhost:8080/jsp/ without the def.html. In short the absolute path was not obtained.
 
Dan Novik
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can collect (record) current request info in the special filter, like something in JSOS: http://www.servletsuite.com/servlets.htm
This info is a "previous page" for the next request
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!