Hello.
First decided to try custon taglib
java class
package RU.Tags.Examples; import javax.servlet.jsp.tagext. *; import javax.servlet.jsp. *; import java.io. *; public class CustomAttribute extends SimpleTagSupport {private String message; public void setMessage (String msg) {this.message = msg; } StringWriter sw = new StringWriter (); public void doTag () throws JspException, IOException {if (message! = null) out.println ("The first custom tag:" + message); } else {/ * use message from the body * / getJspBody (). invoke (sw); getJspContext (). getOut (). println (sw.toString ()); }}} custom_tag_attribute.tld is located in WEB-INF / jstl / custom_tag_attribute.tld
<?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <description>JSTL 1.1 core library</description> <display-name>JSTL core</display-name> <tlib-version>1.1</tlib-version> <short-name>CustomAttribute</short-name> <tag> <name>Hello</name> <tag-class>RU.Tags.Examples.CustomAttribute</tag-class> <body-content>scriptless</body-content> <attribute> <name>message</name> </attribute> </tag> </taglib> calling custom taglib in jsp
examples.jsp is located in the root folder of the project newproject / examples.jsp
<%@ taglib uri="/WEB-INF/jstl/custom_tag_attribute.tld" prefix="CustomAttribute" %> <CustomAttribute:Hello message="This is custom tag" /> Everything would be fine, but this option works if the project works in the root folder for example localhost: 8000 / examples.jsp
If to address in such a way, http: //localhost/newproject/examples.jsp, an error occurs
HTTP Status 500 - Unable to find taglib "CustomAttribute" for URI: /WEB-INF/jstl/custom_tag_attribute.tld type Exception report message Unable to find taglib "CustomAttribute" for URI: /WEB-INF/jstl/custom_tag_attribute.tld Description The server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to find taglib "CustomAttribute" for URI: /WEB-INF/jstl/custom_tag_attribute.tld
How is it possible to eliminate this error?