Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

purge cached sessions?

 
John Smith
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that was it, thanks!
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have any JSP pages, you'll have to turn off Session creation in each of those pages as well.
 
allen catadman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic