• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

include - directive and action

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ include file="somePageOfText.ext" %>

"The directive tag instructs the JSP compiler to merge contents of the included file into the JSP before creating the generated servlet code. It is the equivalent to cutting and pasting the text from your include page right into your JSP. "

This includes file somePageOfText.ext in the page. Question is, does it get the content in the page before starting the execution of jsp page ? So no matter where include directive is in the jsp code, it will be executed first and content if the included page will be pasted at the top of the page and whatever is the output of the generated servlet code will be attached to this included file content. Is this correct ?

----------------------------------------------------------------------------

<jsp:include page="someJSP.jsp" />

This action directive, whenever encountered in the code, will execute this code and put the content in the original jsp page at the location where this include action is placed.
Does it mean that <jsp:include ...... /> can be placed anywhere in the jsp code ? I have seen this "include" action always at the beginning of the page.

The only difference between action and directive is that directive can be placed anywhere in the code but it will be executed first and its content will always be at the top of the page. It can include only static page. While in case of include action, it can include dynamic pages and its content will be placed at the location where its placed.

Please correct me whereevr I am wrong.





 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So no matter where include directive is in the jsp code, it will be executed first and content if the included page will be pasted at the top of the page and whatever is the output of the generated servlet code will be attached to this included file content. Is this correct ?




Nope. Both include directive and jsp:inlcude are position specific.

The difference is include directive makes the jsp to include the content in the translation phase and both ( included jsp and main jsp ) gets compiled after that.
Where as jsp:include includes the data at runtime , when page is being requested. Basically this achieved by kind of RequestDispatcher include() as you do in servlet.
 
reply
    Bookmark Topic Watch Topic
  • New Topic