Explain Different Types Of Tags In JSP Interview Asked Questions And Answers

Different Types Of Tags In JSP


Java Sever Page (JSP) is an abstraction for servlet in which we have less java code and more tags(HTML and JSP). A JSP page is basically used for views with dynamic data(unlike HTML) and evolved basically for people who do not know java and still work at j2ee server side programming.

Depending upon the type of the usage the tags in JSP page are categorized as :


  1. Scripting Tags
  2. Standard Action Tags
  3. Custom Tags

Scripting Tags : These tags are meant for compile time and translation.This means that these tags are meant for translation of code to the servlet. Different types of scripting tags are:

a. Directive Tag

b. Declarative Tag

c. Scriptlet Tag

d. Expression Tag


a. Directive Tag : There are three types of directive tags :

1.Page Directive : It is used for imports,encoding etc.

Example: <%@ page import=”…” %>

2.Include Directive : Its is used for static inclusion of JSP and HTML pages

Example: <%@ include file=”anotherJsp.jsp” %>

3.Tag lib Directive: It is used for including tag libraries

Example: <%@ taglib uri=”…” prefix = “..”%>

b. Declarative Tag : These tags are used to declare variables or methods for the servlet translated servlet class.

Example: <%! int i =0;%>


c. Scriptlet Tag : These tags are used to write java code inside the JSP page.What goes inside the scriptlet tag is merged into the service method of the translated servlet code.

Example: <% System.out.println(“Hello”);%>


d. Expression Tag : These tags are used to print expressions.What is written inside this tag goes as an argument for out.print() inside the service method of the translated servlet.

Example : <%= “Hello” %>


It should be noted that we do not use semicolon inside expression tag because it will go as an argument in ou.print() function,hence will result in syntax error.While in case of declarative tag and scirptlet tag we use semicolon.

Number of View :1128

Tags: , , , , , , , , , , ,

  1. No comments yet.

Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Stephen Fry proof thanks to caching by WP Super Cache