• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP not cached using jsp:forward from it

 
Oscar Calderon
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all. I was reading the thread and i have a doubt about a problem that i have with my application related to jsp:forward use. In my application, when user logouts, i want to restrict that user sees the information when press Back browser button, so when user logouts i load a jsp that contains a piece of javascript with the next code:



And a jsp:forward tag that redirects to another jsp, lets say, threejsp.jsp. I expect that, when the user is in threejsp.jsp and press Back button, load the second jsp that contains the history.forward to return him to threejsp.jsp , but instead that it returns to the first jsp. My conclusions are that the second jsp isn't cached because goes from third jsp from first jsp and avoids second jsp.

I just wanna know if that situation is related to use jsp:forward and if that's the case, if exists a way to cache the jsp that uses jsp:forward
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to restrict that user sees the information when press Back browser button

Why do you want to mess with someone's broswer back button. Is it yours? Did you loan them that browser? Then don't do that.

When the user logs out, expire the session.

And a jsp:forward tag that redirects

There is a language barrier here.
 
Oscar Calderon
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And a jsp:forward tag that redirects

Ok i know that i wrote that bad, i mean
And a jsp:forward tag that forwards

About session, i delete all from session but doesn't matter, for example i'm seeing information about my user account, and press logout button, it forwards me to, let's say, logout.jsp , that contains a <jsp:forward tag that forwards to login.jsp.

Logout.jsp contains a javascript that automatically makes the same that does browser Forward button, so i hope that, when i'm in login.jsp and press the back button of the browser, it sends me to logout.jsp and because logout.jsp has that javascript code, it bounces me to login.jsp. But the problem is that it doesn't do that, back button sends me to the page where i was seeing information about my user account. Obviously, if inside it i press a link on the menu or something like that, user authentication logic is triggered and it redirects me to some page that indicates that my session has expired, but i dont'w want to permit that situation.

So it looks like the jsp that contains <jsp:forward isn't cached or something like that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are confusing caching with history. JSP pages should never be cached, but the URLs are recorded in the history.

Also, remember that a forward is a server-side action and the browser knows nothing about it.
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What that means is that when you are looking at your page with user info, and your "logout button" forwards to logout.jsp, and that forwards to login.jsp, none of that page navigation happens in "your" browser. It happens at the server.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic