Show TOC Start of Content Area

Procedure documentation Including and Forwarding Requests in a JSP  Locate the document in its SAP Library structure

Including Requests

Use the jsp:include action to include other resources in your JSP page. The resources are included when the JSP page is requested, as opposed to resources included with the include directive as described in Using the taglib and include Directives. 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

The index.jsp page of the car rental application uses the jsp:include action within a switch-case cycle, placed in a scriptlet to include the other JSP pages of the application that refer to the different steps in making the car reservation:

<%

  switch (step){

    case 1: %><jsp:include page="step1.jsp" flush="true"/><% break;

    case 2: %><jsp:include page="step2.jsp" flush="true"/><% break;

    case 3: %><jsp:include page="step3.jsp" flush="true"/><% break;

    case 4: %><jsp:include page="step4.jsp" flush="true"/><% break;

    case 5: %><jsp:include page="step5.jsp" flush="true"/><% break;

    default: %><jsp:include page="step1.jsp" flush="true"/><%

  }

%>

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. The response to the current request is again generated entirely by the other page.

 

End of Content Area