This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes RequestDispatcher.forward attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "RequestDispatcher.forward attributes" Watch "RequestDispatcher.forward attributes" New topic
Author

RequestDispatcher.forward attributes

Ian Perkins
Greenhorn

Joined: Dec 18, 2003
Posts: 19
Hi,
The Web Services Tutorial (1.4) says that:
p665...
"When a request is forwarded, the request URI is set to the path of the forwarded page. The original URI and its constituent parts are saved as request attributes javax.servlet.forward.[request_uri|context-path|servlet_path|path_info|query_string]."
The first sentence is true but I cannot find the attributes mentioned in the second sentence anywhere in the request which arrives in the forwarded resource (in my case, it is a servlet).
Please can someone explain where these attributes can be found? Also, if they are there somewhere, then do the names mentioned in the tutorial represent String vales for the names used to retrieve the attributes?
I am using Tomcat 4.1.24 on Windows XP in case it is relevent...
Thanks
Ian
Shankar Narayana
Ranch Hand

Joined: Jan 08, 2003
Posts: 134
Hi,
When u forward the request to the another page using the forward method, u can access all the request parameters on the new page. As far as the statement is saying, it might be internally transmitting it as attributes but still u can access ur request parameters with request.getParameter method or if u have set any attributes urself, u can access them by request.getAttribute("<attribute name>").


"Failure is not when you fall down; its only when you fail to get up again."
Ian Perkins
Greenhorn

Joined: Dec 18, 2003
Posts: 19
Shankar,
Thanks for your reply but perhaps I did not fully explain my question...
If I 'include' another servlet and then look in the request passed into the 'included' servlet doXXX method then I do indeed see some attributes which the server has created - in other words I don't have to do anything except retrieve these attributes using the names given in the tutorial.
However, if I 'forward' to a servlet, there are no added attributes in the request when it arrives in the 'forwarded' resource.
This seems to be at odds with what the tutorial suggests - in fact there is also an objective in SCWCD 1.4 which mentions these attributes but I don't know why the forwarding mechanism is not establishing them.
Regards
Ian
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RequestDispatcher.forward attributes