Can I call a JSP, then have it return control to the original JSP, like a subroutine or method call?
Created May 4, 2012
<jsp:include page="relativeURL" flush="true" />
You can have the include action anywhere within your JSP page, and the relative URL specified for the page attribute may point to either a static (.html) or dynamic resource like a servlet or JSP. Since the include action is handled during the request processing phase, it makes sense to include only resources which generate some dynamic content. The included resource is also automatically forwarded the request and response objects of the invoking JSP page. For example, the action:
<jsp:include page="/examples/jsp/copyright.jsp"flush="true"/>
results in the output of copyright.jsp being included inline within the response of invoking JSP page.
There is however a limitation. The included JSP or servlet resource cannot change the HTTP headers. For example, they cannot set cookies, since they are sent to the browser via the HTTP headers.