aspose file tools*
The moose likes JSP and the fly likes regarding log-out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "regarding log-out" Watch "regarding log-out" New topic
Author

regarding log-out

Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
I facing problem regarding sign-out.
when i sign out from my application and click back button its again going to back page
which should not happen.
I invalidated the session also in log-out jsp .

I can not disable back button(using JS) as it will disable back button in my whole application.

Please suggest me the way to solve this problem.
thanks.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

This is a common problem. You will need to disable cache from the browser. I suppose you are not able to do any action after you press the back button as the session is invalidated and I hope that in your code you've appropriate checks to validate the user's session. So assuming that, you just need to stop the browser from storing your page in cached. Searching in the forum or google would give you good results. This is one of my search in the forum...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
Thanks Ankit for your reply.
You are right .After back ,i am not able to do any thing.I am getting null pointer exception.
But how to disable cache from broser ?
Is there any specific code for that?
If you have any idea please guide me.thanks once again.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

tushartrue fasate wrote:
But how to disable cache from broser ?

Have you looked at the search link the Ankit pointed ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
I searched and i got various results on this topic .I pasted following stuff into my JSP

<%
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-store");
response.setHeader("Expires","0");
response.setDateHeader("Expires",-1);
%>


but still the problem is not resolved.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Try putting this code in a page displayed after you click 'Log Out' action.
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
I pasted it in log-out jps.
I am having mainMenu.jps and logOut.jps.
mainMenu jsp is having log-out hyperlink.
I tried it in both the JSPs ..but problem is there.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I think, the scriptlet code works for single request/response cycle, thus not caching only that page into browser memory.

I suggest using JavaScript this can be solved. Search "disable back button" in JavaScript forum section and you will get many post similar to your need.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

Well you'll have to add those response headers to every page on which you want to disable caching. You cannot add it to logout page and think that it will work on every page...
 
 
subject: regarding log-out