954,167 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Difference between <%@include%> and <jsp:include>

Hi friends
Can anyone tell me about the difference between <%@include file="abc.jsp" %> and :-/

sree22_happy
Light Poster
43 posts since Mar 2006
Reputation Points: 10
Solved Threads: 1
 

Think of the include directive as a header file of languages like C/C++. When using the include directive, the combined contents of the original JSP page and all its included resources are translated into the same implementation servlet i.e. the contents of the included resource is copy pasted before translation to a servlet. The important thing here is that all this happens during translation time and only static content is supported.

The include action is almost similar to the include directive except for a few subtle differences. The include action is executed at request time as opposed to translation time. Thus instead of the content of the include file being included in the calling JSP, the output of the JSP is included or passed to the JSPWriter of the calling page. This allows us to include both static and dynamic content into the JSP page. Using the jsp action also allows you to explicitly pass parameters to the included page.

<jsp:include page="/index.jsp">
  <jsp:param name="name" value="sos" />
</jsp:include>
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
 

thanks for the answer !

sree22_happy
Light Poster
43 posts since Mar 2006
Reputation Points: 10
Solved Threads: 1
 

Can we include htmls via <%@include%>

haribol
Newbie Poster
1 post since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You