Difference between JSP include directive and JSP include action

Last modified on October 5th, 2014 by Joe.

Comments on "Difference between JSP include directive and JSP include action"

  1. Jignesh says:

    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.

  2. Vishal Kakade says:

    Excellent explanation..

    Thanks a lot Jignesh

  3. J says:

    Hey,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!

  4. chandu says:

    Hi 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

  5. saritha says:

    what is the jsp life cycle process,i want to know how containers checking whether the jsp page is modified or not?

  6. suman says:

    good explanation…thank you very much..

  7. S P Sarkar says:

    I 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.
    With thanks – S P Sarkar

  8. Jay says:

    I have 1 question that,
    What 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)?

  9. jyotsana says:

    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?????

  10. Ramesh Kr. Verma says:

    JSP include directive is used to include header banners and footers.
    This line is very use for any user.I thing that this line is proper understanding the difference ………..

  11. Madhusudhan Reddy says:

    The above is my sum.jsp

  12. muthu says:

    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)
    2)

  13. Debasis says:

    Joe,

    Have a small doubt…Will appreciate if you reply.

    Can we use jsp include action to call an action class in struts??

  14. amit says:

    very nice explanation.
    Thanks

  15. Neeraj says:

    Thanx for clearing the concept in the most easy way…

  16. laveena says:

    Clear explanation
    Thank you

  17. Sangeetha says:

    Very nice explanation which is very simple to understand.

  18. Chandrasekar says:

    Simple and clear explaination. thanks

  19. Anonymous says:

    hi if the including jsp content is keep on changing,in this case which include i have to use whether directive or action tag?

  20. Anonymous says:

    very best diferent in the WTED

  21. Anonymous says:

    I have a unique issue. We’re using a JSP to serve up a dynamic home – landing page for our web app. The dynamic home-landing pages are all HTMLs. We’d like to leave them in the htdocs folder on the web server vs. having to include them on the App Server in the same folder as the driving JSP.

    We can use <jsp:include page=="” /> include action or a <c:import url="” /> TAG but in either case the HTMLS must be located in the same folder as the JSP file on the App Server side of the fence.

    How can I include the dynamic home-landing pages in the JSP leaving them in the htdocs folder back on the Web Server without paying the performance penalty to retrieve them on every runtime iteration? Any changes to the HTMLS would also need to be displayed with a re-compile of the JSP.

  22. Kapil says:

    Hey, I have a question…

    I want to send a request from a JSP page to a servlet….and then I want servlet to send response to the same JSP page….

    I am not getting the servlet response on the same JSP page….

    Please help me find out the solution…

    Regards!

  23. ramesh says:

    i hav one question?
    how to display errors in page with out action

  24. Ams says:

    How can I include the dynamic HTML’s which are residing in the htdocs folder on the Web Server in the JSP and also retrieve them on every runtime iteration as any changes to the HTMLS also need to be displayed in the JSP without neccesarily re-compiling the JSP.

  25. SAN says:

    Thanks for your Superb explanation.

  26. Vino says:

    like to share the diff. in another way,which I found in net.

    JSP include directive –
    if a declartion (variable/method) exist in both page (Source page & Included page)
    error will be thrown.

    JSP include action – Since works like a function call , duplication error wont occur.

  27. venkata says:

    explanation is not good

  28. Sutapa says:

    nice explanation.

  29. Pankaj Sinha says:

    Very nice explanation :)

  30. kalai says:

    then wat u r expecting..???

  31. smilyface says:

    Hi Joe,
    Have you ever seen a Servlet exception (Stream closed) while you including a jsp (in any method) ? I am facing such an issue for a long time. I have page definition tags includes another JSPs and getting a ‘Stream closed’ exception..!!!
    email : linuxeverywhere at gmail

  32. Anonymous says:

    good job joe

  33. Srinivasu says:

    Then Definitely you have to use the JSP Include Action Tag element.

  34. Anonymous says:

    thank you so much

  35. Uren Patel says:

    Correct… I got the same problem. Thanks for hint :)

  36. anony says:

    plz. tell me the correct difference between class and constructor

  37. sandeep says:

    remove the girls photo add from this site.because the student or employee are not able to open this site in college or at work place.

  38. Rhishikesh says:

    can you please give the contents of B.jsp file.

  39. Rhishikesh says:

    use a forward slash(/) before included file inditing that the system will interpret the url relative to the home directory of the web server
    eg

    or else use a absolute url as

  40. pankaj says:

    Hello Dear,
    i also came across the same problem.Were u able to find a solution for it?Have you tried with GlassFish Server?

  41. Amit says:

    Very useful….Thanks………..Keep up the good work……..

  42. Somnath says:

    Where does the code goes in side servlet of both( Page directive and )after page parsed and servlet made by JSP container?

  43. Prethesh Kumar Bhalotia says:

    Thanks for the nice explanation. It really helped me a lot.

  44. sagar mamodiya says:

    if you use include directive,then it will not generate any problem.Always remember ,include directive inserts the file at the time the jsp page is translated into a servlet whereas include action inserts the file at the time the page is requested.So in the case of directive include ,b.jsp has the file a.jsp ,it means you can access the variable i in the b.jsp.But in the case of action include sometimes it will work and sometimes it will not work….because action is considered as a separate process.But you can resolve that problem using the concept of and you should use request.getParameter(“i”) in the b.jsp….

  45. Anonymous says:

    joe,

    when I change the page that is include.. those changes are reflecting
    with include directive why so ?

Comments are closed for "Difference between JSP include directive and JSP include action".