RE: servlet chaining, session null
ok, but it's between the second and the third servlet that the problem appears !!! -Message d'origine- De: Bo Xu [SMTP:[EMAIL PROTECTED]] Date: jeudi 17 mai 2001 20:52 À:[EMAIL PROTECTED] Objet: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
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
RE: servlet chaining, session null
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
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
RE: servlet chaining, session null
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