tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Novotny <>
Subject getSession(false)
Date Wed, 18 Apr 2001 21:19:07 GMT


    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     
Home: (510) 549-0574        Work: (510) 486-8662
NERSC Distributed Computing

View raw message