What is the difference between jsp:include page and @ include file?

By: Karthik Printer Friendly Format    


Question: What is the difference between <jsp:include page = ... > and 
<%@ include file = ... >?.
Answer: Both the tag includes the information from one page in another. The differences are as follows:
<jsp:include page = ... >: This is like a function call from one jsp to another jsp. It is executed ( the included page is executed  and the generated html content is included in the content of calling jsp) each time the client page is accessed by the client. This approach is useful to for modularizing the web application. If the included file changed then the new content will be included in the output.
<%@ include file = ... >: In this case the content of the included file is textually embedded in the page that have <%@ include file=".."> directive. In this case in the included file changes, the changed content will not included in the output. This approach is used when the code from one jsp file required to include in multiple jsp files.

Most Viewed Articles (in Interview )

What is similarities/difference between an Abstract class and Interface?

What are the life-cycle methods of JSP?

Interview Question: Why do we need Struts?

Interview Question: How does Struts work?

Interview Question: Where can I get a copy of Struts?

Interview Question: Why aren't the Struts tags maintained as part of the Jakarta Taglibs project ?

Interview Question: What is ActionServlet?

Interview Question: What is Deployment descriptor?

Interview Question: Can I invoke Runtime.gc() in an EJB?

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

Interview Question: What is lazy loading?

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: What are the call back methods in Entity bean?

Interview Question: What is abstract schema?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Latest Articles (in Interview)

Comment on this tutorial