JSP tutorial: include tag

JSP tutorial: include tag


JSP (JavaServer Pages)

include tag

Directive tag--<%@ include file   %>
You can use <%@include file %> directive tag to include html file or jsp in to you jsp file.
Example: in this example, we have three files: Logo.htm, DisplayCurrentDate.jsp, and Welcome.jsp. We will include Logo.htm and DisplayCurrentDate.jsp in to Welcome.jsp. Logo.htm will display an image referring our web page logo displayed on the top Welcome.jsp page and DisplayCurrentDate.jsp page will display below other text.

Logo.htm


<html>
<body>
<img src="images/image442.gif"  alt="Logo" height="72" width="184" />
</body>
 
</html>
 

DisplayCurrentDate.jsp


<html>
<body>
<%=new java.util.Date() %>
</body>
</html>
 

Welcome.jsp


<html>
<head>
  <title>Welcome Page</title>
</head>
<body style="Background-color:silver">
 
<!--Logo.htm is included here   -->
<%@ include file="Logo.htm" %>
<% out.println("<H1>Welcome to our learning center!</H1>"); %>
<%@ include file="DisplayCurrentDate.jsp" %>
 
</body> </html>

Comments

tt comment

 tt

tt


2017-02-27



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.