I've got a different problem.

I have a method called getHttpSession(request, response), as below:
HttpSession getHttpSession(HttpRequest request, HttpResponse response)
{
    HttpSession session = req.getSession(false);
    if ( session==null)
    {
        System.out.println("session = null";
    }
    else
    {
        .....................
    }
    return session;
}

which returns an HttpSesion, this method is in BaseServlet, then I create a
new servelt called Login which extend from BaseServlet, this method was
invoked in Login servlet.

When I run the Login servlet, in IE, sometimes I get session=null, and I
also get some error message said "the instruction in address xxxxxxxxxx is
not correct", or something like that, sometimes I can get correct session,
but in Netscape, I never get session=null.

Did you try your servlet both on IE and Netscape? If so, do they come with
different result?

Becky

----- Original Message -----
From: "Jason Novotny" <[EMAIL PROTECTED]>
To: "Stuart Thomson" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, April 26, 2001 1:51 PM
Subject: Re: getSession(false)


>
>     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               [EMAIL PROTECTED]
> > > Home: (510) 549-0574        Work: (510) 486-8662
> > > NERSC Distributed Computing http://www-didc.lbl.gov
>
> --
> Jason Novotny               [EMAIL PROTECTED]
> Home: (510) 610-8360        Work: (510) 486-8662
> NERSC Distributed Computing http://www-didc.lbl.gov
>
>
>
>

Reply via email to