Forward a JSP Page

Whenever the request comes from the client or browser
then two objects are created by the container, one of request object and the
second one is of response object. The request object goes to the
controller then the controller decides by which jsp or servlet this request will
be processed, then the request object is passed to that jsp or servlet and the
output is displayed to the browser by the response object.
Sometimes it happens that the particular request is not
be able to performed fully by the jsp or servlet for which the browser has send
the request, but it has the reference of the jsp or servlet that can perform the
rest of the processing, and in the URL you can see the page to which the request
has been forwarded. In this whole process only one request object and response
object will do the whole thing.
The code of the program is given below:
<jsp:forward page="gotForwardedRequest.jsp"/>
|
<html>
<head><title>Request forwarded here</title></head>
<body>
This page received a forwarded request from
<b>getRequest.jsp</b>,
<br>This page is the output from <b>gotForwardedRequest.jsp</b>,
<br>but the URL is for <b>getRequest.jsp</b>.
</body>
</html> |
Output of the Program is given below:

Download this example.

|
Current Comments
0 comments so far (post your own) View All Comments Latest 10 Comments: