Which statements about RequestDispatcher are true (where applicable, assume the RequestDispatcher was not obtained via a call to getNamedDispatcher())? (Choose all that apply.)
A. A RequestDispatcher can be used to forward a request to another servlet.
B. The only method in the RequestDispatcher interface is forward().
C. Parameters specified in the query string used to create a RequestDispatcher are not forwarded by the forward() method.
D. The servlet to which a request is forwarded may access the original query string by calling getQueryString() on the HttpServletRequest.
E. The servlet to which a request is forwarded may access the original query string by calling getAttribute(�javax.servlet.forward.query_string�) on the ServletRequest.
Originally posted by Vishal Pandya:
Still the picture is fuzzy.
--------------------------------------------------------------------
[221] Answer D of question 12.;
The text indicates answer D (which refers to
HttpServletREquest.getQueryString) is not correct and answer E (which refers to javax.servlet.forward.query_string) is correct. However, according to page of 62 of version 2.5 (MR6) of the Servlet Spec "servlet-2_5-mrel2-spec.pdf":
"
...
javax.servlet.forward.query_string
The values of these attributes must be equal to the return values of the
HttpServletRequest methods ..., getQueryString, respectively, invoked on the request object passed to the first servlet object in the call chain that received the request from the client. ..."
Therefore, either D and E are both correct or they are both incorrect, and it is clear from the spec that they are
Author comment:
Needs more research
--------------------------------------------------------------------
scjp5, scwcd5
SCJP, SCWCD, SCBCD
Originally posted by Deepak Jain:
Cesar,
Could you please post the result.
scjp5, scwcd5
SCJP, SCWCD, SCBCD
Originally posted by cesar valencia:
you should try it yourself, i'll post some sample code:
SCJP, SCWCD, SCBCD
SCJP, SCWCD, SCBCD
Originally posted by Deepak Jain:
What happens if you replace
RequestDispatcher reqDispatch = getServletContext()
.getRequestDispatcher("/siguiente.do");
with
RequestDispatcher reqDispatch = getServletContext()
.getRequestDispatcher("/siguiente.do?newParam=test");[/QB]
Originally posted by seetharaman venkatasamy:
i am not getting the desire ouput.
what do you say about this ? any reason for this..please explain me
Originally posted by Deepak Jain:
With above knowledge lets try to answer the original question
A RequestDispatcher can be used to forward a request to another servlet.
This is completely wrong since a request dispatcher can forward requests to servlet, JSP file, or HTML file on the server.
Hence A is wrong.
Originally posted by Deepak Jain:
D. The servlet to which a request is forwarded may access the original query string by calling getQueryString() on the HttpServletRequest.
This is wrong. If parameters are specfied in the getRequestDispatcher() of the destination source then those parameters will be passed to the destination resource and the query string [or parameters] of the source will not be passed. Once inside Destination resource a call to getQueryString() will get the new query String that was used to invoke the destination resource.
Hence D is wrong.
scjp5, scwcd5
knowledge is the difference between drudgery and strategic action -- tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|