In the upcoming example, we are going to forward the client request to another web page using the shortcut syntax of <jsp:forward> action, such as -
<jsp:forward page="URL" />
First we are going to take user's inputs in a form on a web page EnterData1.jsp and as soon as the user press the submit button on the form, the information entered will be
sent over to the web page JspForward.jsp(specified in the action attribute of <form> tag).
<title>Using JSP config object</title>
Name : <input type ="text" name="Username">
City : <input type="text" name="Cityname">
<input type ="submit" value ="submit">
Next, in the JspForward.jsp web page, the information entered in the form passed to it by the EnterData1.jsp
is forwarded to another web page ShowData.jsp,
and a new parameter named message is added by using the <jsp:forward> action element.
Next, the web page ShowData.jsp is displayed with the data entered by the user in the form on EnterData1.jsp,
and the value of parameter message, which was added to the request
using on the page JspForward.jsp, is accessed using the JSP's inbuilt request object.
As you can see in the output windows shown below, user's inputs taken in a form on a web page EnterData1.jsp. The entered
information is sent
to the web page JspForward.jsp(specified in the action attribute of <form> tag), when the submit button is clicked.
On the web page JspForward.jsp,
a new parameter is appended to the request using the
<jsp:forward> action and forwarded to ShowData.jsp, where all this information is displayed by using the forwarded JSP request object.