What is the difference between JSP include page and <%@ include file?

Asked By: Abdelhay Sipple | Last Updated: 3rd February, 2020
Category: technology and computing web development
4.4/5 (106 Views . 14 Votes)
1) Include directive includes the file at translation time (the phase of JSP life cycle where the JSP gets converted into the equivalent servlet) whereas the include action includes the file at runtime.

Click to see full answer


Besides, what is the difference between include and JSP include?

1) The most cirtical difference between @include and <jsp:include> is that the include directive is processed at the translation time but include action i.e. <jsp:include> is processed at the request time i.e. when the request comes for processing.

Furthermore, what is JSP include tag? The jsp "include" tag is used to include the resource at the request time. It is better for dynamic web page. The include tag, which inserts the file at the time when jsp page is translated into Servlet. The include tag is used to include another resource it may be jsp or html page in the current jsp.

Subsequently, one may also ask, how does JSP include work?

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.

Why do we use directives in JSP?

JSP directives are the messages to JSP container. They provide global information about an entire JSP page. JSP directives are used to give special instruction to a container for translation of JSP to servlet code. Directives can have many attributes by comma separated as key-value pairs.

37 Related Question Answers Found

What are the two ways to include the result of another page?

There are two ways to include the result of another page:
  1. By include directive.
  2. By include action.

What is JSP life cycle?

JSP Life Cycle is defined as translation of JSP Page into servlet as a JSP Page needs to be converted into servlet first in order to process the service requests. The Life Cycle starts with the creation of JSP and ends with the disintegration of that.

What difference is between include action and include directive in JSP?

The main difference between include directive and include action is that JSP includes action provides dynamic inclusion. The content of another JSP or HTML page is included at request time, which any change you make in the file to be included will be visible to another JSP when requested.

What are implicit objects in JSP?

JSP - Implicit Objects. These Objects are the Java objects that the JSP Container makes available to the developers in each page and the developer can call them directly without being explicitly declared. JSP Implicit Objects are also called pre-defined variables.

What are the advantages of JSP over servlet?


JSP is helpful for UI developers, as it combines HTML with some basic Java coding, and the server side processing logic, can be taken care of by the Servlets. JSP has the custom tags feature , which allows us to create reusable components, making it more flexible, compared to servlets.

What is the difference between servlet and JSP?

Servlet is html in java whereas JSP is java in html. Servlets run faster compared to JSP. JSP can be compiled into Java Servlets. JSP is a webpage scripting language that can generate dynamic content while Servlets are Java programs that are already compiled which also creates dynamic web content.

What is doGet and doPost method in servlet?

doGet is called when a HTTP GET request is made. doPost is when a HTTP POST request is made. This happens with HTML FORMs (those with METHOD=”POST” specified in the FORM tag). In doPost method , form data is sent in separate line in the body. Data that can be sent is not limited.

How do I forward a page in JSP?

To forward a request from one page to another JSP page we can use the <jsp:forward> action. This action has a page attribute where we can specify the target page of the forward action. If we want to pass parameter to another page we can include a <jsp:param> in the forward action.

Can we include JSP in HTML?

HTML files are static resources that are served as is, without any kind of interpretation, by the web container. This will include your jsp. You cannot include a JSP to a HTML page.

Which one is the correct order of phases in JSP life cycle?


Which one is the correct order of phases in JSP life cycle? Explanation: The correct order is Compilation, Initialization, Execution, Cleanup.

HOW include JSP in another JSP file?

use url pattern instead of parameter. At 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.

What is JSP param?

Passing Parameters using <jsp: param>
This tag forwards the request object containing the client request from one jsp file to another file. The targeted file can be a Html file, jsp file or any other servlet file. This tag is used to pass the name and values to the targeted file.

What is JSP useBean?

The jsp:useBean action tag is used to locate or instantiate a bean class. If bean object of the Bean class is already created, it doesn't create the bean depending on the scope. But if object of bean is not created, it instantiates the bean.

Which tag is used to add an object to session?

JSP Action Tags – jsp useBean, include, forward. JSP provides a bunch of standard action tags that we can use for specific tasks such as working with java bean objects, including other resources, forward the request to another resource etc.

What is page directive in JSP?


The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code the page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page.

Which JSP action tags is used to include the content of another resource it may be JSP HTML or Servlet?

The jsp:include action tag is used to include the content of another resource it may be jsp, html or servlet. The jsp include action tag includes the resource at request time so it is better for dynamic pages because there might be changes in future.

Which of the following option helps to include a HTML JSP file into another?

JSP include action tag – JSP Tutorial. Include action tag is used for including another resource to the current JSP page. The included resource can be a static page in HTML, JSP page or Servlet. We can also pass parameters and their values to the resource which we are including.