File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Re: Navigation Restriction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Re: Navigation Restriction" Watch "Re: Navigation Restriction" New topic
Author

Re: Navigation Restriction

Joe Cheung
Ranch Hand

Joined: Oct 18, 2002
Posts: 104
Dear all,

I want to prohibit the users to navigate in our web application back and forth using the "Back" and "Forword" button by raising the the error "page not found" in the browser? Should I use HttpSession to handle it?

Thank you very much!

Joe


Joe
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
yes, this can be achieved with HttpSession. But take care that the no-cache meta is set in the jsp or else the the page contents will be picked from the cache.
ex : <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> has to be set in jsp.
Joe Cheung
Ranch Hand

Joined: Oct 18, 2002
Posts: 104
Other than defining <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> in JSP, what else I should do in order to prevent user to navigate using buttons?

Joe
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
you cannot "prevent" the user from using the Back and Forward button. But if you dont want to use HttpSession, you can use a javascript.


put this in the jsp and when "Back" is clicked,the user will be redirected to the page from which Back was clicked.
Joe Cheung
Ranch Hand

Joined: Oct 18, 2002
Posts: 104
What if I want to use HttpSession to implement it? Could you please provide me with sample code for it?

Thanks!
Joe
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
I tried running this code in Tomcat(4.1.30) and did not work. As I predicted earlier, it is picking from the cache.
I will try this with websphere and see how it works.

But you can take this code and try for yourself..anyone else in the forum can help?







PS: The HEAD tag before the close of HTML tag is required as a fix to IE. IE wants that to not cache (but still caches..probably another Bill Gates issue)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Re: Navigation Restriction
 
Similar Threads
counter offer
".. not in our son's name."
Have you received this email?
Y do u do this 2 ur posts
WA #1.....word association