Includes a static file or sends a request to a dynamic file.


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


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


The <jsp:include> element allows you to include either a static or dynamic file in a JSP file. The results of including static and dynamic files are quite different. If the file is static, its content is included in the calling JSP file. If the file 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 file.

You cannot always determine from a pathname if a file is static or dynamic. For example, http://server:8080/index.html might map to a dynamic servlet through a Web server alias. The <jsp:include>element handles both types of files, so it is convenient to use when you don't know whether the file is static or dynamic.

If the included file is dynamic, you can use a <jsp:param> clause to pass the name and value of a parameter to the dynamic file. As an example, you could pass the string username and a user's name to a login form that is coded in a JSP file.


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

    The relative URL that locates the file 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 file. If it is absolute (beginning with a /), the pathname is resolved by your Web or application server.

  • flush="true"

    You must include flush="true", as it is not a default value. You cannot use a value of false. Use the flush attribute exactly as it is given here.

  • <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 file. The included file should be dynamic, that is, a JSP file, servlet, or other file 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 file. 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.

'Web Develop. > JSP' 카테고리의 다른 글

JSP 페이지 구성요소  (0) 2014.10.12
Include Directive  (0) 2014.09.30
<jsp:include>  (0) 2014.09.30
EL(Expression Language)  (0) 2014.09.23

+ Recent posts