<jsp:forward>

The <jsp:forward> action passes the request-processing control to another JSP page or servlet in the same web application. The execution of the current page is terminated, giving the target resource full control over the request.

When the <jsp:forward> action is executed, the buffer is cleared of any response content. If the response has already been committed (i.e., partly sent to the browser), the forwarding fails with an IllegalStateException.

The action adjusts the URI path information available through the implicit request object to reflect the URI path information for the target resource. All other request information is left untouched, so the target resource has access to all the original parameters and headers passed with the request. Additional parameters can be passed to the target resource through <jsp:param> elements in the <jsp:forward> element’s body.

The <jsp:forward> action supports the attribute described in Table 1-4.

Table 1-4. Attributes for <jsp:forward>

Name

Java type

Request-time value accepted

Description

page

String

yes

Mandatory. A page- or context-relative URI path to which the resource will forward users.

Example:

<jsp:forward page="list.jsp" />

Get JavaServer Pages Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.