I have found problems when you are you using separate contexts for servlets
that share session information on the server.
I don't know if the crosscontext flag helps this.
Ross

-----Original Message-----
From: Bo Xu [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 17, 2001 12:52 PM
To: [EMAIL PROTECTED]
Subject: Re: servlet chaining, session null


[EMAIL PROTECTED] wrote:

> Well,
>
> all my servlets are on the same webapps.
> I don't use the url rewriting, but the HttpSession.
>
> for example in the first servlet:
> HttpSession session = request.getSession(false);
> if (session == null)
>  session = request.getSession(true);
> session.setAttribute("path1",request.getServletPath());
> RequestDispatcher dispatch =
>
this.getServletContext().getRequestDispatcher("/servlet/chaining.Servlet2");
> dispatch.forward(request,response);
>
> in Servlet2
> HttpSession session = request.getSession(false);
> session.setAttribute("path2",request.getServletPath());
> RequestDispatcher dispatch =
>
this.getServletContext().getRequestDispatcher("/servlet/chaining.Servlet3");
> dispatch.forward(request,response);
>
> I do the same in the third servlet, but when i test my session, it's
null.
>
> That's funny, but it only happen the first time i send the request, the
> second time, everything works fine !!!
> [...]

Hi :-)  I am not sure, is the following possibe?
in the first time, because you use getRequestDispatcher, so the new
cookie which includes "JSESSIONID" made by MyServlet1 "hasn't
got the time Yet to goto :-)" MyServlet2/3.

in the second time, that cookie(made by MyServlet1) has already been
"received" by the browser of your client, and re-sent to MyServlet1/2/3,
so now in MyServlet2/3, session is not null.


Bo
May.17, 2001

Reply via email to