Home Jsp How JSP Forwards a request



How JSP Forwards a request
Posted on: August 5, 2008 at 12:00 AM
In this section you will study how jsp forwards a request.

How JSP Forwards a request

     

In this section you will study how jsp forwards a request. 

The <jsp:forward>  forwards the request information from one resource to the other, for example, one jsp file to other. To forward a request from one page to other, following syntax is required which forwards the request to other page. If a string or an expression represents the URL to forward the page, use the syntax:

<jsp:forward page={"relativeURL" | "<%= expression %>"} />

If you want to send one or more name/value pairs as a parameters, use the syntax:

 <jsp:forward page={"relativeURL" | "<%= expression %>"} >
 <jsp:param name="parameterName"value="
   {parameterValue | <%= expression %>}" />+
 </jsp:forward>

Here is the code of forward.jsp:

<%@ page language ="java" %>
<html>
<head><title>jsp forwarding a request</title></head>
<jsp:forward page="/jsp/welcome.jsp"/>
</html>

The above jsp page forwards the request to welcome.jsp page by using <jsp:forward page="/jsp/welcome.jsp"/>

Here is the code of welcome.jsp

<%@page language="java" %>
<html>
<head><title>jsp forwarding a request</title></head>
<body>
<h3><b>Welcome!</b></h3>
This is a JSP forward request Example.
Request is forward here.
</body>
</html>

This is the requested page.

Output will be displayed as

Download Source Code

Related Tags for How JSP Forwards a request:
cstringjspfileurlsyntaxormuiformioformatrequestpageexpressionsourceresourcewarjsifforexampletoexpressexamrequireinformationssieilaxusefromforwardceinrminfomnttrjestaxagercxawhichxampsspsoessatquestisirinfllmplpressprefollowarstrreprrdsxpwingssriringrdthstatiinforminformatpleplpronomolo


More Tutorials from this section

Ask Questions?    Discuss: How JSP Forwards a request  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.