Custom Tag is a user-defined JSP language element. When it is contained in JSP page and it will translate into a servlet, the custom tag is converted to opertions on an object called a tag handler. The web container then invokes those operations when the JSP page’s servlet is executed.

If we want to create a custom tag, what we need to do is simply extend SimpleTagSupport class and override the doTag() method, where you can place your code to generate content for the tag.

Let’s getting started to create a custom tag now.
As you can see below, consider we want to create two tag, one is user tag with name and isMale attribute, another is system tag with size attribute.

1
2
<custom:user name="user1" isMale="true"/>
<custom:system size="1024"/>