Includes a static file or the result from another web component.
<jsp:include page=
"{relativeURL| '${' Expression '}' | <%=
expression%>}
"[ flush="true
| false" ]
{ /> | > [ <jsp:param name="parameterName" value="{parameterValue | '${' Expression '}' | <%= expression %>}" />] + </jsp:include> }
<jsp:include page=
"{relativeURL| '${' Expression '}' | %=
expression%}
"[ flush="true
| false" ]
{ /> | > [ <jsp:param name="parameterName" value="{parameterValue | '${' Expression '}' | %= expression %}" />] + </jsp:include> }
<jsp:include page="scripts/login.jsp" /> <jsp:include page="copyright.html" /> <jsp:include page="/index.html" /> <jsp:include page="scripts/login.jsp"> <jsp:param name="username" value="jsmith" /> </jsp:include>
The jsp:include
element allows you to include either a static or dynamic resource in a JSP page. The results of including static and dynamic resources are quite different. If the resource is static, its content is included in the calling JSP page. If the resource is dynamic, it acts on a request and sends back a result that is included in the JSP page. When the include action is finished, the JSP container continues processing the remainder of the JSP page.
You cannot always determine from a pathname if a resource is static or dynamic. For example, http://server:8080/index.html might map to a servlet through a server alias. The jsp:include
element handles both types of resources, so it is convenient to use when you don't know whether the resource is static or dynamic.
If the included resource is dynamic, you can use a jsp:param
clause to pass the name and value of a parameter to the resource. As an example, you could pass the string username
and a user's name to a login form that is coded in a JSP page.
page=
"{ relativeURL | <%=
expression %> }
"
String
equivalent to the relative URL.
/
), the pathname is resolved by your web or application server.
flush="true
| false"
flush
attribute is given a true value, the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush
attribute is false
.
<jsp:param name="parameterName" value="{
parameterValue | <%=
expression %>}" />+
jsp:param
clause allows you to pass one or more name/value pairs as parameters to an included resource. The included resource should be dynamic, that is, a JSP page, servlet, or other resource that can process the parameter.
jsp:param
clause if you want to send more than one parameter to the included resource. The name
attribute specifies the parameter name and takes a case-sensitive literal string. The value
attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at request time.