jsp:include Tag

The <jsp:include> tag lets you 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.

For more information, see the JavaServer Pages (JSP) v1.2 Syntax Reference on the Sun Microsystems® web site.

Syntax

<jsp:include page="{ relativeURL | <%= expression %> }" flush="true | false" />

Or:

<jsp:include page="{relativeURL | <%= expression %>}" flush="true| false" >
  <jsp:param name="parameterName"
  value="{parameterValue | <%= expression %>}" />
</jsp:include>

Attributes

page="{ relativeURL | <%= expression %> }"

The relative URL that locates the resource to be included, or an expression that evaluates to a String equivalent to the relative URL. The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a /), the pathname is resolved by your web or application server.

flush="true | false"

If the page output is buffered and the 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 %>}" />

The <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. You can use more than one <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.

Examples

<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>

Related Topics

jsp:fallback Tag

jsp:forward Tag

jsp:getProperty Tag

jsp:param Tag

jsp:params Tag

jsp:plugin Tag

jsp:setProperty Tag

jsp:useBean Tag

JSP Tag Reference for Page Flows