Is it possible that your session has ended (too long between requests)?
Check how long you have configured sessions to be active (in web.xml).  Is
it possible you are losing the encoded session ids (if cookies are not being
used)? It's easy to miss an encoded URL on a page for get/post and thus lose
the session id on the next request.  Then again, I've seen bugs before in
which cookies are quite reliable, but encoded URLs don't always seem to
work.

David

----- Original Message ----- 
From: "Mark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 12, 2004 8:36 AM
Subject: request.getSession(false) randomly returns null in servlet


> Hi All,
> I have unstable behavior in my web application when I try to get
> HttpSession.
> The problem is that the following code randomly returns _null_ for
> HttpSession.
>
> But next http request from different servlet using the same code is
> fine. and when I call servlet with problem I've got null again.
> Interesting, that if I wait for few minutes, this problem does not
> exists: I'm getting a session object with no problems
> Here the code:
>
> ------ cut ------
> public void doPost( HttpServletRequest req, HttpServletResponse resp
> )
>       throws IOException, ServletException
>   {
>     String cPath = req.getContextPath();
>     HttpSession ses = req.getSession(false);
>     /* ... ses is null sometimes ;(*/
> ....
> ----- end cut ----
>
>
> Please note that I use req.getSession(true) in the login servlet and
> DO know that session is created.
>
> Tech spec:
>  Software: tomcat 5.0.24 on Redhat FS2
>  Hardware: AMD 2700+, 512Mb, 120 GB HDD.
>
>
> Any comments and suggestions are welcome.
>
> Thanks,
> Mark.
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
> http://mobile.yahoo.com/maildemo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to