Re: Tomcat 4.0 Beta3 and Request Attributes Error - why me ?
Hello Ana, Wednesday, May 02, 2001, 8:23:09 PM, you wrote: A Hi, Hello! A We think we have discovered an error. That's nice! But why are you mailing me? I'm not a tomcat developer! :-) Best regards, Anthonymailto:[EMAIL PROTECTED]
RE: Tomcat 4.0 Beta3 and Request Attributes Error
RequestDispatcher.forward() returns immediately BUT the JSP page has not been processed yet! The JSP page will only be processed after the servlet finishes the work, i.e., your doGet or doPost returns. Therefore, there is no way to access attributes in the JSP page inside the calling servlet. Cheers, Charles Chen -Original Message- From: Ana [mailto:[EMAIL PROTECTED]] Sent: 02 May 2001 17:23 To: : Subject: Tomcat 4.0 Beta3 and Request Attributes Error Hi, We think we have discovered an error. We call the include method of the RequestDispatcher from a servlet. Then, we call the setAttribute method of the request object of the included JSP. If we call the getAttribute method of the request object in the servlet (after the include call), then there is not attribute. Example: MyServlet.java: ... public void service(ServletRequest request, ServletResponse response){ ... getServletConfig().getServletContext().getRequestDispatcher(MyJSP.jsp).for ward(request, response); Object obj = request.getAttribute(MyAttribute); // obj is null ... } MyJSP.jsp: ... request.setAttribute(MyAttribute, obj); ... Thank you. _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: Tomcat 4.0 Beta3 and Request Attributes Error
On Wed, 2 May 2001, Ana wrote: Hi, We think we have discovered an error. We call the include method of the RequestDispatcher from a servlet. Then, we call the setAttribute method of the request object of the included JSP. If we call the getAttribute method of the request object in the servlet (after the include call), then there is not attribute. Yes, you definitely found an error. The spec is silent on whether an included servlet can modify the request attributes of the request it receives, but it seems like an obviously useful thing that should be possible. I just checked in a patch to fix it, which will show up in tonight's nightly build (20010503). Craig McClanahan
Re: Tomcat 4.0 Beta3 and Request Attributes Error
On Wed, 2 May 2001, Ana wrote: Hi, We think we have discovered an error. We call the include method of the RequestDispatcher from a servlet. Then, we call the setAttribute method of the request object of the included JSP. If we call the getAttribute method of the request object in the servlet (after the include call), then there is not attribute. Yes, you definitely found an error. The spec is silent on whether an included servlet can modify the request attributes of the request it receives, but it seems like an obviously useful thing that should be possible. I just checked in a patch to fix it, which will show up in tonight's nightly build (20010503). Really ? According to the spec (#8.3), I was under the impression that the included servlet couldn't do anything but : - Write data to either the Writer or the OutputStream - Access (and I understood that as read) the request object So to be consistent with what is done with everything else, I wouldn't allow the modification. Perhaps we should ask the question to Danny ;-) Remy
Re: Tomcat 4.0 Beta3 and Request Attributes Error
On Wed, 2 May 2001, Remy Maucherat wrote: On Wed, 2 May 2001, Ana wrote: Hi, We think we have discovered an error. We call the include method of the RequestDispatcher from a servlet. Then, we call the setAttribute method of the request object of the included JSP. If we call the getAttribute method of the request object in the servlet (after the include call), then there is not attribute. Yes, you definitely found an error. The spec is silent on whether an included servlet can modify the request attributes of the request it receives, but it seems like an obviously useful thing that should be possible. I just checked in a patch to fix it, which will show up in tonight's nightly build (20010503). Really ? According to the spec (#8.3), I was under the impression that the included servlet couldn't do anything but : - Write data to either the Writer or the OutputStream - Access (and I understood that as read) the request object So to be consistent with what is done with everything else, I wouldn't allow the modification. Perhaps we should ask the question to Danny ;-) For those who don't know who Danny is, that is Danny Coward -- specification lead for the servlet spec. I did ask. He agreed that it's not spec'd but that it makes sense to give the included servlet a sense that it is talking to the same request that the calling servlet is, even though it's not technically true. The only change that the original servlet can make when it accesses the request is to set or remove attributes, so an included servlet should be able to as well. Remy Craig