JSP include Action Tag

JSP include Action Tag

This tag is used to include some external resources at runtime response. It may be JSP page, html file, or servlet. This tag includes resources at request time so it’s better for dynamic pages. It can be used to include both static or dynamic pages.

 

Now you will think that what is difference between JSP include directive and JSP include Action tag. Let ‘s see how they both are differ.

  1. JSP include directive include resources during translation phase but JSP include Action tag include resources during request phase.
  2. JSP include directive is better for static page but JSP include Action tag is better for dynamic page.
  3. JSP include directive includes original content in generated servlet but JSP include Action tag calls the include method.

The main advantage of this Tag is Code Reusability which means we can use a page many times like i have created header so i can use it in many pages, it saves time.

 

Syntax:

Syntax with Parameter:

Example: Let’s understand it by an simple example.

 

#header.html: Create a header html file so that we can include it in our JSP file.

#index.jsp: here we will include above header file, check below code.

Output: The output of this code will look like below image.

1