| Author |
javax.servlet.forward AND javax.servlet.include
|
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
The forwarded-to servlet and the included servlet has access to 5 request attributes each. javax.servlet.forward.request_uri javax.servlet.forward.context_path javax.servlet.forward.servlet_path javax.servlet.forward.path_info javax.servlet.forward.query_string AND javax.servlet.include.request_uri javax.servlet.include.context_path javax.servlet.include.servlet_path javax.servlet.include.path_info javax.servlet.include.query_string Can I have an example with values for all these request attributes? Thanks in advance.
|
Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
|
 |
Niranjan Deshpande
Ranch Hand
Joined: Oct 16, 2005
Posts: 1277
|
|
Can I have an example with values for all these request attributes? Thanks in advance. In the destination servlet, just make a meryod call - request.getAttribute("............."); you can replace the dots by any of the attributes above. the only condition is, the disptcher with which you forward the request, must be obtained as - request.getRequestDispatcher( ) or getServletContext().getRequestDispatcher( ) the above attributes are not set if you use the getNamedDispatcher( ). htht
|
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
|
 |
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
Hi All, My example's output alone for your quick reference! What was done? Forwarder.jsp simply forwards the request to Forwarded.jsp. Forwarded.jsp also includes response from Included.jsp All 3 JSPs in the same folder. My request url http://localhost:9090/mani-examples/jsp/Forwarder.jsp?name="Mani" Output of Forwarded.jsp javax.servlet.forward.request_uri = /mani-examples/jsp/Forwarder.jsp javax.servlet.forward.servlet_path = /jsp/Forwarder.jsp javax.servlet.forward.context_path = /mani-examples javax.servlet.forward.path_info = null javax.servlet.forward.query_string = name="Mani" Output of Included.jsp javax.servlet.include.request_uri = /mani-examples/jsp/Included.jsp javax.servlet.include.servlet_path = /jsp/Included.jsp javax.servlet.include.context_path = /mani-examples javax.servlet.include.path_info = null javax.servlet.include.query_string = null Things to Note 1. Query String parameter reflects the query string of the forwarding page. 2. Where as, request_uri, servlet_path, context_path reflect the information of the forwarded page.
Can someone explain the path_info ?
|
 |
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
Can anyone explain me, what will be contained in path_info. I understood all the other attributes. How to demonstrate path_info attribute?
|
 |
varigireddy reddy
Greenhorn
Joined: Jun 25, 2010
Posts: 2
|
|
check this for all the values
http://myj2eelearnings.blogspot.com/2010/06/javaxservletforward-and.html
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1066
|
|
Hi Manikandan,
Query String parameter reflects the query string of the forwarding page.
Not exactly: all the attributes reflect information of the forwarding page.
With the include attributes it is the other way around: they reflect information about the included page instead of the including page.
Regards,
Frits
|
 |
 |
|
|
subject: javax.servlet.forward AND javax.servlet.include
|
|
|