09/05/2008
- <%@ include file=”filename” %> is the JSP include directive.
At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a staticĀ resource orĀ a JSP page. Generally JSP include directive is used to include header banners and footers.The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.
- <jsp:include page=”relativeURL” /> is the JSP include action element.
The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters.If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.














I believe there is a limit of 64kb size in JVM for method. So the include directive can run into trouble as its all one method. Whereas the action is considered a separate process.
Jignesh on December 18th, 2009 1:39 amExcellent explanation..
Thanks a lot Jignesh
Vishal Kakade on December 2nd, 2010 9:12 amHey,thanks for the explanation above! However, i’ve got one question.. my static change in the included file was updated when i’m using them in JSP include directive.. I came across the issue that time stamp attribute must be disabled in the JSP container for Tomcat web server in order to avoid this issue. Would you be able to assist me as i had a hard time searching online for a solution..many thanks for your help!
J on December 5th, 2010 1:45 pmHi i have a doubt . I am having two jsp pages A and B.In A.jsp i am declaring int i=5; and including B.jsp(in this i am having some statements) and Printing using out,println(i) in A.jsp. what is the output when we use directive include and action include …? can any body let me know
chandu on January 8th, 2011 2:37 pmwhat is the jsp life cycle process,i want to know how containers checking whether the jsp page is modified or not?
saritha on April 16th, 2011 3:46 amgood explanation…thank you very much..
suman on June 23rd, 2011 9:41 pmI am a banker with interest in programming. I am trying to learn JSP by reading ebooks. I try the examples given in the books. Although I am able use , but in case of jsp: include – I am not able to run the page. This may be because of problem with URI . Can you please give me a comple example with location of included file ?
Please also name good ebook on JSP that is freely available on net.
S P Sarkar on August 16th, 2011 3:26 pmWith thanks – S P Sarkar
I have 1 question that,
Jay on September 8th, 2011 9:47 amWhat if there are 2 jsps a.jsp and b.jsp which includes one other jsp having code int a =10; in its scritptlet
a.jsp is having directive include and b.jsp is having include action then which jsp will print value of System.out.println(a)?
i m using netbeans 6.7.1 for jsp and servlet. my problem is that my logic code does not work in jsp page, it can only displays the design and not logic. i tried in scriptlet, expression anything, whats the problem?????
jyotsana on September 10th, 2011 3:54 pmJSP include directive is used to include header banners and footers.
Ramesh Kr. Verma on September 15th, 2011 6:26 amThis line is very use for any user.I thing that this line is proper understanding the difference ………..
SUM OF TWO NUMBERS IS
h1{color:#778899}
.visitor{color:#883322;font-family:GraublauWeb;}
SUM OF TWO NUMBERS IS
number of visitors of this site are
GO TO HOME
Madhusudhan Reddy on October 5th, 2011 12:00 pmThe above is my sum.jsp
Madhusudhan Reddy on October 5th, 2011 12:01 pminput two numbers
h1
{
text-align:center;
font-family:Viner Hand ITC;
color:#778899;
}
input.red {background-color: #cc0000;}
Enter numbers
footer
GOOD BYE
SUM OF TWO NUMBERS IS
h1{color:#778899}
.visitor{color:#883322;font-family:GraublauWeb;}
SUM OF TWO NUMBERS IS
number of visitors of this site are
GO TO HOME
welcome
I AM IN MIDDLE
My proble is here in middle.jsp i included the sum.jsp bu using which is a dynamic page eventhough i make changes in the sum.jsp then getting reflected in my output y like that? please help me where i went wrong?
Madhusudhan Reddy on October 5th, 2011 12:07 pmThank for ur help in advance.
Joe,
I have one question ..
Assume filename is some jsp file then
how many servlet file will be created at run time for below tags
1)
muthu on November 24th, 2011 7:00 am2)
Joe,
Have a small doubt…Will appreciate if you reply.
Can we use jsp include action to call an action class in struts??
Debasis on November 30th, 2011 3:33 pmvery nice explanation.
amit on December 22nd, 2011 12:38 pmThanks
Thanx for clearing the concept in the most easy way…
Neeraj on January 19th, 2012 2:33 amClear explanation
laveena on March 9th, 2012 3:43 pmThank you
Very nice explanation which is very simple to understand.
Sangeetha on March 20th, 2012 10:05 pmSimple and clear explaination. thanks
Chandrasekar on April 19th, 2012 8:47 pmhi if the including jsp content is keep on changing,in this case which include i have to use whether directive or action tag?
Anonymous on April 20th, 2012 3:31 pmvery best diferent in the WTED
Anonymous on April 26th, 2012 10:14 am