praneeth gajji wrote:Can any one please explain difference between thease two along with beloww query.
we have one.jsp having defined String s="1" using scriptlet
two.jsp two.jsp having defined String s="2"
three.jsp with String s="3"
we have included two.jsp into one .jsp with <%@include..> directive
Also we have included three.jsp into one.jsp with <jsp:include..> tag
wheras all jsps have String s defined in it, if we print 's' what will be output,please xplain the reason
I think you will get an error because of "Duplicate variable" as two.jsp file is added to one.jsp so the variable 's' also get declared to page one.jsp
and if you just remove String s="1" from one.jsp then the output will be 2.
The output is 2 because of <%@include file="two.jsp"> as the content of this file get included in one.jsp
I think by using <jsp:include...> only output of the file is included.
Correct me if I am wrong
* executes at translation times .
* you can include static references such as jsp fragments.
* you cant pass parameter to include file
=> so when you include a file(say A.jsp) into another(say B.jsp) ,
then container copies the A.jsp into B.jsp at the time of .java file generation[this is what called as translation time].
so, think of it.
<jsp:include page=''/> :
* executes at run time
* you cant include static references such as jsp fragments.
if you do so. it just process as strings.
*you can pass parameter to include file
=> so it is just as *method call* to another jsp content
so think about it.