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 session.invalidate doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session.invalidate doubt" Watch "session.invalidate doubt" New topic
Author

session.invalidate doubt

adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Hi.
I would like to know why the session.invalidate() doent kill the session completely.

If user click the refresh button he can view the logged out pages also, i.e duplicate form submission.

From where the browser is getting back the data???

where that data is stored??

the data which i am telling is the forwarded data from jsp to servlet, at least the jsp fields data should be destroyed, is there any way to do that??

Thanks and Regards
Adeeb.
Sumit Bisht
Ranch Hand

Joined: Jul 02, 2008
Posts: 329

session.invalidate() clears the server side session.
For the client side (browser) session, you will need to make sure the window gets closed (manually/javascript)
you can solve the problem of duplicate submission by using session objects as tokens that are validated on that event.
Your browser stores its data (fields, etc) in form of cookies and autoloads the session information. Try clearing your cache/ form autoload information to solve that.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi adeeb,

you are asking many question in a single post. and really they are *not* clear to me too.

also Please, UseOneThreadPerQuestion
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Thanks for your replies.

In simple words, when i click signout, it is forwarded to logoutservlet, there i have invalidate the session. now when i click back button of browser I get the document expired. That is ok. When i refresh sgain, the page loads. I have gone through the PRG patter, i am unable to implement it, as i am not using any framework. I dint get into my head and trying this since yesterday. . So i was saying that after the page is refreshed i could still see the old data, how come when the session is invalidated? Means this method invalidate is fooling us around?? Some one guide me to a easire way, only one problem and these many



Thanks
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 556

session.invalidate will clear the data, Its not fooling us. If the browser is showing the page, even after session.invalidate, its most likely to be a browser cache..
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Is there any way to clear taht cache using servlet. Is it possible???
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

We have a FAQ entry in JspFaq . NoCacheHeaders . also similar topics discussed many times here. Please Search here for more detail.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 556

check NoCacheHeaders in the servlets FAQ section here..
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
Thanks for quick reply.

But i already added this still the page loads when refreshed..

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

adeeb alexander wrote:
But i already added this still the page loads when refreshed..



Hope you have added them in Jsp. well now did you check the valid session there ? if invalid then did you redirect to login page or some where else?
adeeb alexander
Ranch Hand

Joined: May 29, 2008
Posts: 268
I have tried as you said. Check the below code. Is that what you were saying to do, to check the session?? It dint help, any other way out??


IN JSP





SERVLET



Thanks.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

adeeb alexander wrote: Is that what you were saying to do, to check the session??

ohh. noo... I think first you need to thoroughly understand the scope objects in servlet. by the way : you have any idea about javax.servlet.Filter?

<edit>corrected typo</edit>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session.invalidate doubt