Show TOC

Procedure documentationIncluding and Forwarding Requests in a JSP Locate this document in the navigation structure

Procedure

Including Requests

Use the jsp:include action to include other resources in your JSP page. This is the JSP syntax alternative to the RequestDispatcher.include() method that is used in servlets.

Using the flush attribute of the jsp:include action, you can determine whether or not the buffered output is flushed by the Web Container before the resource is actually included. The value of true will flush the response buffer.

Example Example

The page attribute of jsp:include accepts request-time attribute expressions.

  1. <jsp:include page="step<%step%>.jsp" flush="true"/>
End of the code.
Forwarding Requests

Using the jsp:forward action you can forward the request to be processed by another resource. This is the JSP syntax equivalent of the RequestDispatcher.forward() method that is used in servlets. Similarly, the response buffer and headers are cleared before giving control to the forwarded page. If the response has already been committed to the client, then any attempt to write in the response again leads to IllegalStateException.

In the forwarding page after the call to <jsp:forward> any attempt to write in the response output is ignored.