CodesJava

Easy learning with example program codes

jsp:include action tag


jsp:include action tag is used to include the content of another resource at the specific position into current JSP page. Another resource can be servlet, jsp or html file.

Syntax: <jsp:include page=”URL of another resource”/>

Note: In case of jsp:include action tag contents are included during request processing.

Difference between include directive and include action.

               include directive               include action
  1. In case of include directive contents are included at the translation time.
  2. If the content of included file is changed than changes will not reflect.
  3. Not use RequestDispatcher to include the content.
  4. Can’t pass parameters.
  5. Syntax: <%@ include file=”URL of another resource” %>
  1. In case of jsp:include contents are included at the runtime.
  2. If the content of included file is changed than changes will reflect.
  3. The jsp:include action include the contents using RequestDispatcher.
  4. Can pass parameters using jsp:param action tag.
  5. Syntax: <jsp:include page=”URL of another resource” />

Example:

welcome.jsp

<html>
	<head>
		<title>include action example</title>
	</head>
	<body> 
		<h3>Hello this is a include action example.</h3>
		<jsp:include page="home.jsp"/>
	</body>
</html>

home.jsp

<html>
	<head>
		<title>include action example</title>
	</head>
	<body>
		<h4>This content is of included file.</h4>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>welcome.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 27
 
Download this example.
 
Next Topic: jsp:param action tag with example.
Previous Topic: jsp:forward action tag with example.

Related Topics:

JSP action tags with example.
jsp:forward action tag with example.
jsp:include action tag with example.
jsp:param action tag with example.
jsp:useBean, jsp:setProperty and jsp:getProperty action tag.
Exception handling in JSP with example.
JSP Expression Language with example.

 

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki