• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include page and include file

 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between
<%@include page="something.jsp"%>
<%@include file="something.jsp"%>
JSP spec does explain this but to me it was French (which I don't know)
Thanks in advance
Chintan
 
herve attia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@include file="something.jsp"%>
this directive includes jsp file at Page Translation time.
If the included file changed, all the JSP files that use it need to be updated.
<%jsp:include page="something.jsp"%>
this one includes the file at the time of the client request and does not require you to update the main file when an icluded file has changed.
Regard,

 
Harpreet Hira
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# include directive
<%@ include file="header.jsp" %>
1.The included page can contain only static content or JSP page. Its contents are merged with the page that includes it and the resulting page is converted into a servlet.
2. All the scripting variables declared in JSP declarations, scriptlets, or actions are shared by the main page and all included pages. If the main page declares a variable and the same name is used to declare another variable in an included page, it will result in a translation phase error, since the compiled page cannot be compiled.
# include action
<jsp: include file="header.jsp" flush="true" />
1. The include page can include any type of web resource like servlets,JSP pages or HTML.
2. The action is executed in request processing phase instead of translation phase. The <jsp:include> action doesnot include actual contents of the specified page, it includes the response produced by executing the page.
3. Since the page is not included until the main page is requested, you can use a request time attribute to decide which page to include depending on the runtime condition and request parameters that can be read at runtime.
4. Flush attribute tells whether the response body should be flushed before the page is included or not. If it is true, the included page can face certain limitations like included page cannot set headers, or forward to another page.

------------------
Harpreet S Hira
Sun Certified Java2 Programmer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic