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