GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Regarding TLD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Regarding TLD" Watch "Regarding TLD" New topic
Author

Regarding TLD

Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
Hi,

I placed myFunction.tld file under web-inf directory :

<?xml vesrion="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.0">

<tlib-version>1.2</tlib-version>

<uri>DiceFunctions</uri>

<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature> int rolldice()</function-signature>
</function>

</taglib>

even i chnaged this file name to DiceFunctions.tld

still getting org.apache.jasper.JasperException: File "/DiceFunctions" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Following is my jsp code

<%@ taglib prefix="mine" uri="DiceFunctions" %>

<html>
<body>

${mine:rollIt()}

</body>
</html>
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Try to put a slash "/" in front of the uri (in the TLD and in the JSP as well).


[My Blog]
All roads lead to JavaRanch
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
I tried putting /DiceFunctions in TLd as well in JSP but getting following error

Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/myFun.tld: (line 1, col 20)
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
gar tek
Greenhorn

Joined: Mar 07, 2007
Posts: 10
Try mapping the uri name in web.xml using taglib tag. Remove the slash you added now.
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
even getting the same error
Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/myFun.tld: (line 1, col 20)
org.apache.jasper.servlet.JspServletWrapper.handleJspExceptionRemoved the slash and added

<taglib>DiceFunctions</taglib> in web.xml after <jsp-file> tag

<servlet>
<servlet-name>Hobby Page</servlet-name>
<jsp-file>/TestBean2.jsp</jsp-file>
<taglib>DiceFunctions</taglib>
</servlet>


i think its xml parsing error in tld file..
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
my tld file is


<?xml vesrion="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.0">

<tlib-version>1.2</tlib-version>

<uri>DiceFunctions</uri>

<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature> int rolldice()</function-signature>
</function>

</taglib>
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Put your web.xml, yout tld file and your jsp back as they were at the beginning. You've got the following error :
still getting org.apache.jasper.JasperException: File "/DiceFunctions" not found

I didn't give it a good look the first time, but I believe you're problem is not with the TLD. Are your forwarding the request from a servlet to "/DiceFunctions" ? If so, you've got a servlet mapping problem.
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
now this is my error :

Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/myFun.tld: (line 1, col 20)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

The first line of your file, you've got a very strange tag.
It should read version="1.0", not vesrion="1/0"
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
Hi Satou,

I changed this..Can you please check latest code i posted and reslove the problem..

Thanks
Manju
woo hwang
Greenhorn

Joined: Dec 13, 2006
Posts: 23
I am wondering the mandatory emements for taglib.
which are <tagb-version> and <short-name>.
There are not <short-name> in your code.
I hope it help you
 
GeeCON Prague 2014
 
subject: Regarding TLD