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 !!!
Strange !!!
> -----Message d'origine-----
> De: Bo Xu [SMTP:[EMAIL PROTECTED]]
> Date: jeudi 17 mai 2001 16:29
> À: [EMAIL PROTECTED]
> Objet: Re: servlet chaining, session null
>
> [EMAIL PROTECTED] wrote:
>
> > Hi, i'm trying to use Servlet chaining with three servlets. In the first
> one
> > i create a cession (if it doesn't exist), in the second one i put some
> > attributes in the cession. But when i arrive in the third servlet, my
> > session is null?
> > As anybody already had this problem ?
> >
> > Is it possible to get the path of the servlet who called the last one ?
> > I mean if i am in the ith servlet, how can i get the path of the (i-1)th
> > servlet ?
> > [...]
>
> Hi :-) I am not sure, I just suggest you to notice:
>
> - do you use cookie or url-rewritting or other to make your
> session-tracking?
> if you are using url-rewritting, don't forget to use
> HttpServletResponse.encodeURL/encodeRedirectURL to "encode the
> URL"(make a new URL which includes the JSESSIONID), I guess it
> is also possible to add JSESSIONID by myself with HttpSession.getId()
>
> - from several emails, HttpSession is "within" a special webapp, so if in
> your
> Servlet-chain, you go to another Servlet-class which is in another
> webapp,
> now perhaps another new session will/need-to be made.
>
>
> Bo
> may.17, 2001
>