# jsp:forward Tag

The <jsp:forward> tag forwards the request object containing the client request information from one JSP page to another resource. The target resource can be an HTML file, another JSP page, or a servlet, as long as it is in the same application context as the forwarding JSP page. The lines in the source JSP page after the <jsp:forward> tag are not processed.

You can pass parameter names and values to the target resource by using a <jsp:param> clause. An example of this would be passing the parameter name username (with name="username") and the value nakamura (with value="nakamura") to a servlet as part of the request. If you use <jsp:param>, the target resource should be a dynamic resource that can handle the parameters.

Be careful when using <jsp:forward> with unbuffered output. If you have used the page directive with buffer="none" to specify that the output of your JSP page should not be buffered, and if the JSP page has any data in the out object, using <jsp:forward> will cause an IllegalStateException.

For more information, see the JavaServer Pages (JSP) v1.2 Syntax Reference on the Sun Microsystems® web site.

## Syntax

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

Or:

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

## Attributes

page="{relativeURL | <%= expression %>}"

The relative URL that locates the resource to be included, or an expression that evaluates to a String equivalent to the relative URL. The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a /), the pathname is resolved by your web or application server.

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

Sends one or more name/value pairs as parameters to a dynamic resource. The target resource should be dynamic, that is, a JSP page, servlet, or other resource that can process the data that is sent to it as parameters. You can use more than one <jsp:param> clause if you need to send more than one parameter to the target resource. The name attribute specifies the parameter name and takes a case-sensitive literal string as a value. The value attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at request time.

## Examples

    <jsp:forward page="/servlet/login" />
    <jsp:forward page="/servlet/login">
       <jsp:param name="username" value="nakamura" />
    </jsp:forward>

Related Topics

jsp:fallback Tag

jsp:getProperty Tag

jsp:include Tag

jsp:param Tag

jsp:params Tag

jsp:plugin Tag

jsp:setProperty Tag

jsp:useBean Tag

JSP Tag Reference for Page Flows