Advanced Java (2160707)

BE | Semester-4   Winter-2018 | 20-11-2018

Q1) (a)

What is difference between include directive and jsp:include action tag?

Sr. Include Directive jsp:include action tag
1 Syntax: <%@ include attribute= "value" %> Syntax: <jsp:include page="relative URL" flush="true" />
2 Processed at the translation time Processed at the request time i.e. when the request comes for processing.
3 Include directive can use both relative and absolute path jsp:include action tag always uses relative path.
4 Include Directive can only include contents of resource e.g. HTML or CSS file but it will not process the dynamic resource jsp:include action tag process the dynamic resource and result will be added to calling JSP.
5 You can not pass any other parameter e.g request, response or any configuration We can pass another parameter also using <jsp:param> tags.
6 Cannot pass the request or response object to calling jsp to included file or JSP or vice versa It's possible to pass request/response object.
7 Uses the file attribute to specify the resource to be included and that's why know as file include as well Uses page attribute to specify the resource to be included, hence also known as page include in JSP
8 Example : <%@ include file="1.html" %> Example : <jsp:include page="Action1.jsp" flush="true"> <jsp:param name="roll_no1" value="401" /> </jsp:include>