Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sessions created by magic?

 
Monica Moncho
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a servlet that destroys the current session with invalidate. To get the session I am using getSession(false). The thing is, I am calling this servlet many times in a row and it always seems to destroy a new session. I am displaying the session ID for debugging.

How is this session created each time if I am not creating it. What I am looking for is destroying the session and then not having a new one the next time I call to destroy it.

Anybody knows why I seem to always get a new session? I'm totally confused now.

thanks
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out your JSP pages. Many JSP pages have tags that automatically create a session when they are used. If you are forwarding to a JSP page, it may have an innocuous tag that is creating a new session right after your Servlet kills it.
[ August 27, 2006: Message edited by: Bear Bibeault ]
 
Monica Moncho
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I will investigate that. I am forwarding to a JSP, but I have only this on it:

<%@ page import="java.util.*" %>
<%@include file="top.htm" %>

Who knows, maybe somewhere else. I will recheck my pages to see if I can find it.

Thanks!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default JSPs create a session (if one doesn't already exist).
To stop this behaviour you need to add the following directive to your JSP:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic