File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes container creating session automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "container creating session automatically" Watch "container creating session automatically" New topic

container creating session automatically

Sigrid Kajdan
Ranch Hand

Joined: Jan 14, 2007
Posts: 72

my web app does not use sessions (there's no request.getSession()) anywhere).
But I find that the jsessionid cookie is set anyway!
Can anybody tell me why that's the case? Does Tomcat send the jsessionid cookie automatically?
Thanks a lot,
Stary Kapec
Ranch Hand

Joined: Dec 04, 2005
Posts: 81
Does your application contain jsp pages? If so that is the case. Jsp page implicitly creates new session if none exists. You can turn it off by using page directive with session attribute.

<% page session="false" %>

If you checked the generated java file for the jsp page there you would see HttpSession session = request.getSession(). This is how the implicit jsp session object is initialized. If you turn session off the session object will not be created, check it!
Sigrid Kajdan
Ranch Hand

Joined: Jan 14, 2007
Posts: 72
Yes, it works! Thank you!
I agree. Here's the link:
subject: container creating session automatically
It's not a secret anymore!