JSP Implicit Objects Presentation
https://github.com/studyskymate/J2EEDemos/tree/master/WebContent/jspDemos
Question: Explain include
Directive and include Action of JSP. Answer: This is a very popular interview question
on JSP, which has been asked from a long time and still asked in the various
interview. This question is good to test some fundamental concept like
translation of JSP and difference between translation time and run time kind of
concept. Syntax
for include Directive is : <%@ include file="fileName" %> which means we are
including some file to our JSP Page when we use include directive contents of
included file will be added to calling JSP page at translation time means when
the calling JSP is converted to servlet ,all the contents are added to that
page one important thing is that any JSP page is compiled if we make any
changes to that particular page but if we have changed the included file or JSP
page the main calling JSP page will not execute again so the output will not be
according to our expectation, this one is the main disadvantage of using the
include directive that why it is mostly use to add static resources, like
Header and footer . Syntax for include action is <jsp:include
page=”relativeURL” /> It is a
runtime procedure means the result of the JSP page which is mentioned in
relative URL is appended to calling JSP at runtime on their response
object at the location where we have used this tag. So any changes made
to included page is being effected every time, this is the main advantage of
this action but only relative URL we can use here, because request and response
object is passed between calling JSP and included JSP.
No comments:
Post a Comment