Preface

Comment

Declaration

Expression

Scriptlet

EL Expression

Directives

Attribute Directive

Include Directive

Page Directive

Tag Directive

Taglib Directive

Variable Directive

Standard Actions

<jsp:attribute>

<jsp:body>

<jsp:element>

<jsp:doBody>

<jsp:forward>

<jsp:getProperty>

<jsp:include>

<jsp:invoke>

<jsp:output>

<jsp:plugin>

<jsp:root>

<jsp:setProperty>

<jsp:text>

<jsp:useBean>

<jsp:include>

Includes a static file or the result from another web component.

JSP Syntax

<jsp:include page="{relativeURL | '${' Expression '}' |	
   <%= expression %>}" 	
   [ flush="true| false" ]	
   { /> | > [ <jsp:param name="parameterName"	
      value="{parameterValue | '${' Expression '}' | 	
      <%= expression %>}" />] +	
</jsp:include> }

XML Syntax

<jsp:include page="{relativeURL | '${' Expression '}' |	
   %= expression %}" 	
   [ flush="true| false" ]	
   { /> | > [ <jsp:param name="parameterName"	
      value="{parameterValue | '${' Expression '}' | 	
      %= expression %}" />] +	
</jsp:include> }

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>

Description

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.

Attributes

See Also



宏飞网络是你学习web开发、测试web程序实例、和培养职业技能的首选网站。我们提供例子也许有些简单,但对理解基本概念有帮助。

我们尽量避免在教程、参考及例子中出现错误,但不能保证所有的内容都是正确的。

你使用本网站时,我们默认你已经阅读并接受了我们的隐私政策。

Copyright 2003-2011宏飞网络 版权所有