Javatpoint Logo

difference between include directive include action tag jsp

By: pushpe*** On: Sun Dec 29 15:19:43 IST 2013     Question Reputation-3 Answer Reputation0 Quiz Belt Series Points0  -3Blank User
demo.jsp:

<html>
<body>
<% out.println("Hello Directive");%>
</body>
</html>

include.jsp:

<%@ include file="demo.jsp" %>
<%="Example of include directive" %>

it is example of include directive.in this example if we make any change in he called jsp(here demo.jsp)then calling jsp(here include.jsp) gets update every time automatically while it should not be happen but here it is happening.if it happens then what is the difference between include directive & include action.please give proper explanation...
Up0Down

 

<%@ include file=?filename? %> is the JSP include directive.
At JSP page translation time, the content of the file given in the include directive is ?pasted? as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers.

The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.
<jsp:include page=?relativeURL? /> is the JSP include action element.
The jsp:include action element is like a function call. At runtime, the included file will be ?executed? and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters.

If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.
Image Created0Down

By: [email protected] On: Mon Dec 30 10:43:06 IST 2013 Question Reputation0 Answer Reputation359 Belt Series Points0 359User Image
Are You Satisfied :3Yes0No
 

include directive inserts the source at translation time but the action tag inserts the response at runtime.

and there is an extra performance hit with every action tag.
Image Created0Down

By: [email protected] On: Mon Dec 30 18:21:32 IST 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :0Yes0No
 
you are right sir,but in my example given above if i make any changes in the included jsp page(here demo.jsp) then it reflects the changes which i have made in the included jsp page automatically while the changes in the included jsp page should not be reflected in the source jsp page but in this example source jsp page reflect the changes which i have made in the included jsp page.now my question is that why it reflects the changes of included jsp page in the source jsp page aumatically when i make any changes in included jsp page.Image Created0Down

By: [email protected] On: Tue Dec 31 01:07:34 IST 2013 Question Reputation-3 Answer Reputation0 Belt Series Points0 -3User Image
Are You Satisfied :0Yes0No
 

jsp include example
=================
<%@ page import="java.util.*"%>

o/p of two.jsp
<jsp:include page="three.jsp"/>

two.jsp


<%@ page import="java.util.*"%>

o/p of three.jsp asdfdf newsldfk
<%out.println(new Date());%>

three.jsp


include directive example
=================
<%@ page import="java.util.*"%>

o/p of two.jsp
<%@include file="/three.jsp"%>
<%out.println(new Date());%>

two.jsp


<%@ page import="java.util.*"%>

o/p of three.jsp asdfdf newsldfk
<%out.println(new Date());%>

three.jsp


in above two cases both are giving same out put .could u pls explain with example
Image Created0Down

By: [email protected] On: Fri Aug 14 08:18:51 IST 2015 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No