JSP taglib directive

JSP taglib directive is used in case of custom tags. It specifies the tag library used for custom tags. We will learn more about taglib directives in the custom tag section.


Attributes of JSP taglib directive:

  1. uri: This attribute specifies the location of the tag library.
  2. prefix: This attribute is to inform the web container that this markup is used for custom actions.



<%@ taglib uri="uri" prefix="prefixForCustomTag">




import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

 * This class is used for defining a custom tag.
 * @author W3schools360
public class CustomTag extends SimpleTagSupport{
	public void doTag() throws JspException, IOException {
      JspWriter out = getJspContext().getOut();
      out.println("This is our first custom tag.");



     <short-name>Our first custom tag</short-name>



<%@ taglib prefix="ftag" uri="WEB-INF/firsttag.tld"%>
        <title>custom tag example</title>