Search code examples
javajspcustom-tag

error in mapping custom tag in jsp


When i try map custom tag, i am getting Error: 500 with a message File "/customTag" not found

Here is my attempt: myTag.tld

<taglib version="2.0" xmlns="http://java.sun.com/xml/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    >
    <uri>customTag</uri>
    <tlib-version>1.0</tlib-version>
    <tag>
        <name>multiplier</name>
        <tag-class>myPack.MultiplierTag</tag-class>
        <attribute>
                <name>input</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>

</taglib>

jsp page

<%@taglib uri="/customTag" prefix="operator"%>
<%
    String input = request.getParameter("input");
%>
<operator:multiplier input="<%=input%>"></operator:multiplier>

When i am trying to access .tld file using file name then everything is fine


Solution

  • In TLD file: Add short-name and change uri from customTag to /customTag

    <short-name>operator</short-name>
    <uri>/customTag</uri>
    

    In JSP

    <@ taglib prefix="operator" uri="/customTag" />