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 directive in custom tag section.

Attributes of JSP taglib directive:

1. uri.

2. prefix.

1. uri: This attribute specify 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 w3spoint
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>




jsp example 67
Download this example.
Next Topic: JSP implicit objects with example.
Previous Topic: JSP include directive with example.


Content Protection by DMCA.com
Please Share