File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Difference between %include file= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Difference between %include file=""%  and  jsp:include file=""" Watch "Difference between %include file=""%  and  jsp:include file=""" New topic

Difference between %include file=""% and jsp:include file=""

Markandey Sahu

Joined: Jun 29, 2006
Posts: 13
Can any one tell me difference between <%include file=""%> and <jsp:include file=""> and which one is faster?
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
If you have file index.jsp,

<%@ include file="header.html" %>
This is index page
<jsp:include page="footer.jsp" />

content of header.html file is copied to inclduing page at translation time.

With <jsp:include page="footer.jsp" /> will include content of footer.jsp at request time.

When first jsp is translated to servlet java class in case of directive it includes file content (at translation time contents are included).

With jsp:include a runtime call is included to footer.jsp so when user requests index.jsp at that time footer.jsp contents will be included (at request time) and response will be sent to client.

For more information please read some book or do google.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10031

Refer here to point number 11...

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
you can refer to the David Bridgewater's book..chapter 7...for some good graphical explanation...

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
I agree. Here's the link:
subject: Difference between %include file=""% and jsp:include file=""
It's not a secret anymore!