JSP Include Tag with Param Tag:
This tag is similar to the include directive but the difference is that the file is included during the request processing while the directive being at the translation phase.
Syntax:
<jsp:includepage="relative URL"flush="true"/>
Attribute | Description |
page | A JSP or a relative URL of a JSP if that is not in the current project folder. |
flush | The boolean attribute determines whether the included resource has its buffer flushed before it is included. |
We can also pass parameters and their values to the resource which we are including. This type of tag is called as Dynamic Include tag and if sent without the parameters are named as Static Include Tag.
Now let’s see a simple static call:
We use two JSP’s : include.jsp & put.jsp
include.jsp:
<%@ 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>Include Action Tag</title>
</head>
<body>
<p>This is from the include.jsp main page. </p>
<jsp:include page="put.jsp" />
<p> This is from the include.jsp main page after include statement. </p>
</body>
</html>
put.jsp:
<%@ 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>Insert title here</title>
</head>
<body>
This is the content which is present in put.jsp
</body>
</html>
Now when running the include.jsp we have the below output.

table.jsp:
<%@ 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>Dynamic Include action JSP</title>
</head>
<body>
<table width="100%" border="1" style="width:300px">
<tr>
<td><%=request.getParameter("variable1")%></td>
<td><%=request.getParameter("variable2")%></td>
<td><%=request.getParameter("variable3")%></td>
<td><%=request.getParameter("variable4")%></td>
<tr>
<td> Personal </td>
<td> Mobile </td>
<td> IPhone </td>
<td> Apple </td>
</tr>
<tr>
<td> Office </td>
<td> Photo </td>
<td> Scenery </td>
<td> GoodLook </td>
</tr>
</table>
</body>
</html>
dcall.jsp:
<%@ 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>Dynamic call in Include Action</title>
</head>
<body>
<jsp:include page="table.jsp">
<jsp:param name="variable1" value="Type" />
<jsp:param name="variable2" value="Products" />
<jsp:param name="variable3" value="Services" />
<jsp:param name="variable4" value="Company Profile" />
</jsp:include>
</body>
</html>
The output of the above code:
