File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Re: Navigation Restriction

 
Joe Cheung
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sripathi Krishnamurthy
Ranch Hand
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic