Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 82679 invoked by uid 500); 26 Apr 2001 18:51:24 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 82669 invoked from network); 26 Apr 2001 18:51:23 -0000 Received: from c453707-a.pinol1.sfba.home.com (HELO bullwinkle.lbl.gov) (root@24.11.139.217) by h31.sny.collab.net with SMTP; 26 Apr 2001 18:51:23 -0000 Received: from lbl.gov (IDENT:novotny@bullwinkle.lbl.gov [127.0.0.1]) by bullwinkle.lbl.gov (8.11.0/8.11.0) with ESMTP id f3QIp1N03932; Thu, 26 Apr 2001 11:51:01 -0700 Sender: novotny@bullwinkle.lbl.gov Message-ID: <3AE86E15.6DE0FF7D@lbl.gov> Date: Thu, 26 Apr 2001 11:51:01 -0700 From: Jason Novotny X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.2 i686) X-Accept-Language: en MIME-Version: 1.0 To: Stuart Thomson CC: tomcat-user@jakarta.apache.org Subject: Re: getSession(false) References: <3ADE04CA.B63FBB8C@lbl.gov> <3AE541DB.CD6906B4@swtsoft.demon.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N No- but my lame workaround is to stick something in the session and test to see if it's null in which case I explicitly set session to null. e.g. HttpSession session = req.getSession(false); // Unless a user profile exists, the session is null if (session != null) { Object user = session.getAttribute("user"); if (user == null) session = null; } Jason Stuart Thomson wrote: > Did you ever find out what was causing this? I seem to be hitting the > same problem. > > Jason Novotny wrote: > > > > Hi, > > > > I'm using the following snippet in my main servlet: > > > > public void service(HttpServletRequest req, HttpServletResponse res) > > throws ServletException, IOException { > > > > HttpSession session = req.getSession(false); > > if (session == null) { > > System.out.println("session is null"); > > } else { > > System.out.println("session is not null"); > > } > > > > } > > > > what I find is that when I go to the servlet, I first see "session is > > null". Fine by me, and since I passed "false" to getSession, I expect > > not to have one created. However, when I reload the page, now I get > > "session is not null". can anyone please explain why getSession(false) > > actually creates a session, or what I might be doing wrong. > > > > Thanks, Jason > > > > -- > > Jason Novotny novotny@george.lbl.gov > > Home: (510) 549-0574 Work: (510) 486-8662 > > NERSC Distributed Computing http://www-didc.lbl.gov -- Jason Novotny novotny@george.lbl.gov Home: (510) 610-8360 Work: (510) 486-8662 NERSC Distributed Computing http://www-didc.lbl.gov