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

purge cached sessions?

John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Developing a Servlet/struts app with tomcat and the sessions being chached is giving me grief, simple changes to files don't register as a different file and the old session is kept, is there a way to purge the cached sessions or something?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm assuming you're having trouble with Tomcat not recognizing changes to JSP pages ?

And so you restart it (which fixes the JSP change problem), but now you have old sessions?

There's a file called SESSIONS.ser that is created when Tomcat shuts down. When it starts up, it is read back in and deleted. You should delete it yourself inbetween stopping and starting TC.

look in: $CATALINA_HOME\work\Standalone\localhost\webapp_folder
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
that was it, thanks!
vicky kumar
Ranch Hand

Joined: Dec 13, 2002
Posts: 55
Hi,
I am using Eclipse 2.2 wit tomcat plugin. I also need to remove any/all session information. I removed all the SESSIONS.SER files under TOMCAT../localhost../ and my Workspace directory. Even after that the following statement

HttpSession session = request.getSession();

in my code always returns me NOT NULL value.
Why is this so. I also have set the saveOnRestart=false in server.xml.

Did someone have the similar experience.
What else I need to do so that I get NULL session.
Any help will be appreciated as I already broken my head on this for long.

Thanks
Vicky
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5

According to the API, this call returns the current session, OR if none exists, a new session. What you want is

the method that does not create a new one and returns null if none exists.
Bill
vicky kumar
Ranch Hand

Joined: Dec 13, 2002
Posts: 55
Hi William,
I changed the code as you mentioned. But :-( the same problem.

protected boolean isSessionAvailable(HttpServletRequest request) {
HttpSession session = request.getSession(false);

if(session == null) return false;

return true;
}

Above code always returns TRUE. Why ??
Do I needs to DELETE something else other than SESSIONS.ser files.

Please let me know.

Thanks
Vicky
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Is it possible that something else in your code is causing new sessions to be created?
You might see if the session isNew() method returns true.
Bill
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

if you have any JSP pages, you'll have to turn off Session creation in each of those pages as well.
allen catadman
Greenhorn

Joined: Apr 16, 2009
Posts: 7
its a tomcat issue.. it works fine in RAD

OT: i got it.. in mac osx i should command Q not just click X.. at work we use windows/RAD thats why it works.. my mistake i should use command Q totally exit safari/firefox not just click X.. so i still into tomcat..
 
 
subject: purge cached sessions?