• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sessions created by magic?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic