Asked by: Zaheer Zerr
asked in category: General Last Updated: 21st February, 2020

How can we create JSP custom tags?

Perform the following steps to create and use custom JSP tags:
  1. Write a tag handler class.
  2. Reference the tag library in your JSP source using the JSP <taglib> directive.
  3. Write the tag library descriptor (TLD).
  4. Reference the TLD in the Web application deployment descriptor ( web.
  5. Use your custom tag in your JSP.

Click to see full answer.


Accordingly, how do I create a custom tag?

For creating any custom tag, we need to follow following steps:

  1. Create the Tag handler class and perform action at the start or at the end of the tag.
  2. Create the Tag Library Descriptor (TLD) file and define tags.
  3. Create the JSP file that uses the Custom tag defined in the TLD file.

Similarly, what are custom tags? A custom tag is a user-defined JSP language element. When a JSP page containing a custom tag is translated into a servlet, the tag is converted to operations on an object called a tag handler. The Web container then invokes those operations when the JSP page's servlet is executed.

Also asked, what is the purpose of creating custom tags?

Custom tags increase productivity because they can be reused in more than one application. Custom tags are distributed in a tag library, which defines a set of related custom tags and contains the objects that implement the tags. The object that implements a custom tag is called a tag handler.

What are the tags in JSP?

There are four types of JSP tags, which are important and often required.

  • Directives. These types of tags are used primarily to import packages.
  • Declarations. JSP declarations starts with '<%!
  • Scriptlets. JSP Scriptlets starts with '<%' and ends with '%>'.
  • Expressions. JSP expressions starts with '<%=' and ends with '%>'.

33 Related Question Answers Found

Which is mandatory in tag?

What is a tag in Java?

Why Taglib is used in JSP?


How do I create a custom TLD?

What is a TLD file?

What is JSP useBean?


What are TLDs in Java?

What is the use of JSTL?

What is Scriptlet in JSP?


What are JSP actions?

What is JSP life cycle?

What is container tag Java?


What is Servlet and its use?

Which tag can be used to define the user defined method in JSP?