This section illustrates you about the
Ads
TutorialsIn this section we will discuss about JSP "include" action tag. The jsp "include" tag is used to include the resource at the request time. It is better for dynamic web page. The include tag, which inserts the file at the time when jsp page is translated into Servlet. The include tag is used to include another resource it may be jsp or html page in the current jsp.
Syntax:
<jsp:include page = relative URL" flush="true" />
Here, page is the relative URL of the page to be included.
<jsp:include page="Welcome.jsp" flush="true"/>
The include tag has following attributes:
When we execute jsp page it is converted into Servlet code in the jsp container. Then the Servlet code is compiled and .class file is created . The .class file is called again whenever the request comes for jsp page. So after compilation of jsp page, whenever we want to add static page or any page which is not required to change rapidly then it is kept inside the directive tag. The jsp include tag is used to include the file or any other resource(i.e. html, jsp).
Example :In this example we have created a jsp file which has to be included in the other jsp file by using the tag <%jsp:included = " "%>, this tag is known as a include tag which will include the file in the jsp file at the translation time. This tag is mostly used to include the static content which doesn't need to be changed frequently.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html"; charset="ISO-8859-1"> <title>JSP include tag Example</title> </head> <body> <jsp:include page="Welcome.jsp"></jsp:include> </body> </html>
This jsp page include "Welcome.jsp" which prints "Rose India Technology Pvt. Ltd."
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>JSP include tag Example</title> </head> <body> <h2>Welcome to Rose India Technology Pvt. Ltd.</h2> </body> </html>
When you execute the program the output will be as follows:
Posted on: July 8, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles
Advertisements
Ads
Ads
Discuss: jsp:include action tag
Post your Comment