spring - how to access my custom jsp taglib in STS 4.3? -
i have spring mvc web app whic i'm developing using sts 4.3 ide.
i decided try hand on custom jsp tag libraries.
these tutorial i'm following: http://www.tutorialspoint.com/jsp/jsp_custom_tags.htm , http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/ , http://blog.denevell.org/tomcat7-el-custom-function.html , many other links (too many list similar in content).
i have configured tomcat7 testing server sts 4.3
i have created new project in sts , called "mycustomutilities".
folder structure of mycustomutilities project: http://i.imgur.com/9neupyw.jpg
source code mycustomutilities.java
package org.flinders.mycustomutilities; import java.lang.stringbuilder; public class mycustomutilities { public static string stringtohtml(string inputstring) { stringbuilder returnstring = new stringbuilder(); char[] inputchar = inputstring.tochararray(); (char c: inputchar) { returnstring.append("&#").append((int) c).append(";"); } return returnstring.tostring(); } }
jsp snippet (i've tried <%@ taglib uri="web-inf/mycustomutilities.tld" prefix="mine" %> still getting error)
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib uri="http://localhost:8080/mycustomutilities.tld" prefix="mine" %>
tomcat folder structure: http://i.imgur.com/ot3ndhp.jpg
i have created system variable called "classpath" , it's pointing root/web-inf (full path of course. shorten here).
here's tld file (unsure on put on uri portion i'm accessing web app on localhost:8080 on browser)
<?xml version="1.0" encoding="iso-8859-1" ?> <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/web-jsptaglibrary_2_0.xsd" version="2.1"> <tlib-version>2.0</tlib-version> <uri>localhost:8080/mycustomutilities</uri> <function> <name>stringtohtml</name> <function-class>org.flinders.mycustomutilties.mycustomutilities</function-class> <function-signature>java.lang.string stringtohtml(java.lang.string)</function-signature> </function> </taglib>
any ideas on how can setup/configured tomcat/sts can see custom tag library? said above, i'm looked @ various examples don't seem complete. thanks
Comments
Post a Comment