To get to know the difference between these two
<%@include file="" %> is a directive
Action tag:
<jsp:include page="{relativeURL | <%= expression %>}" flush="true" />
or
<jsp:include page="{relativeURL | <%= expression %>}" flush="true" >
<jsp:param name="parameterName"
value="{parameterValue | <%= expression %>}" />
</jsp:include>
one.jsp
=========
<%@page isELIgnored="false"%>
<jsp:declaration>int cnt=0;</jsp:declaration>
<jsp:expression>"Shyamala"+cnt++</jsp:expression>
<jsp:include page="two.jsp"/>
two.jsp
==========
I am just included
now go to work directory of tomcat and check out there will be two seperate servlets created
and even u can observe one line in one_jsp.java file
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "two.jsp", out, false);
which specifies the page is included at run time
just change your one.jsp file as following
one.jsp
<%@page isELIgnored="false"%>
<jsp:declaration>int cnt=0;</jsp:declaration>
<jsp:expression>"Shyamala"+cnt++</jsp:expression>
<%@ include file="two.jsp"%>
you will not be created with two different java files in work directory the two.jsp contents also will be included in the same one_jsp.java file.
That means it is done at the time of compilation!!
Rocking !!
Shyamala
No comments:
Post a Comment