#1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2006
    Posts
    529
    Rep Power
    62

    Problem with a .tld file??


    hi all,

    I've a result.jsp file to which a List has been forwarded via the requestdispacher. The List contains 3 Strings. At the moment i've been using scripting and have got the 3 Strings from the list and placed them into a form. All this works fine.

    Underneath the form i'm trying to use customTags to take the same list as an Tag attribute and pass it to the taghandler class, which will then loop through the list invoking the body of the tag with each element of the list. So basically i'll have a form and a table with the data in it.

    I get the following error.

    Code:
    org.apache.jasper.JasperException: Unable to initialize TldLocationsCache: XML parsing error on file /WEB-INF/Client.tld: (line 2, col 15)
    	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)
    	web.EnterClient.doPost(EnterClient.java:32)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    I've googled the error but can't find any info on it. I've got the jstl.jar and j2ee.jar in my classpath and also i've the jstl.jar and standard.jar in root\WEB-INF\lib.

    I know i've got both scripting and tags in my JSP but i'm trying to phase the scripts out

    I don't think there's any need for the <jsp-config> tag for the uri in web.xml as tomcat maps it for you.

    Here are the files involved any help would be apprieciated

    thanks mat

    java Code:
     
    <%@ page import="java.util.*" %>
    <%@ taglib prefix="clientTag" uri="clientTag" %>
     
    <html>
    <body bgcolor=#808080>
    <h1 align="center"> View Client Page</h1>
    <p>
     
     
    <% List client1 = (List)request.getAttribute("theclient"); %>
     
     
     
    <table>
    	<clientTag:client myClient="${client1}">
     
    		<tr>
    			<td>${aClientStr}</td>
     
    		</tr>
     
    	</clientTag:client>
     
    </table>
     
    </body>
    </html>




    xml Code:
     
    <?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.0">
     
     
    <tlib-version>0.9</tlib-version>
     
    <short-name>clientTags</short-name>
     
    <uri>clientTag</uri>
     
    <tag>
     
    	<description>get a client's details using custom tags</description>
    	<name>client</name>
    	<tag-class>web.ClientTagHandeler</tag-class>
    	<body-content>scriptless</body-content>
     
    	<attribute>
    		<name>myClient</name>
    		<required>true</required>
    		<rtexprvalue>true</rtexprvalue>
    	</attribute>
     
    </tag>
    </taglib>



    java Code:
     
    package web;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.tagext.SimpleTagSupport;
    import java.io.IOException;
    import java.util.*;
     
     
    public class ClientTagHandeler extends SimpleTagSupport{
     
    	private List clientList;
     
    	public void setMyClient(List cl){
     
    		this.clientList = cl;
     
     
    	}
     
    	public void doTag() throws JspException, IOException {
     
    		Iterator i = clientList.iterator();
     
    		while(i.hasNext()){
     
    		String s = (String) i.next();
    		getJspContext().setAttribute("aClientStr",s);
    		getJspBody().invoke(null);
     
    		}
     
    	}
    }
    Last edited by turtleboy; July 5th, 2007 at 12:07 PM.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2006
    Posts
    529
    Rep Power
    62
    hi all,

    I've cleaned up the above jsp and only left the parts that are giving me trouble.

    I've been searching the net for the following error, but with no luck. It seems to be a common error but nobody give a solution.

    Code:
    Unable to initialize TldLocationsCache: XML parsing error
    Has anyone here had this experience with this type of error in Tomcat? What would cause Tomcat to do this?

    thanks in advance
  4. #3
  5. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    Chicago, IL
    Posts
    10,131
    Rep Power
    5058
    You're missing an opening quote mark on this line:

    <taglib xmlns=http://java.sun.com/xml/ns/j2ee"
    The forum's syntax highlighting shows you that...

    ~

    Comments on this post

    • turtleboy agrees : Thanks again
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2006
    Posts
    529
    Rep Power
    62
    Originally Posted by Yawmark
    You're missing an opening quote mark on this line:



    The forum's syntax highlighting shows you that...

    ~
    Why is it the simple things that cost you one day of your life

    It worked but i got a NPE from the tag attribute. Got that solved though with the following line

    java Code:
     
    pageContext.setAttribute("myclient1", client1, PageContext.REQUEST_SCOPE);


    Thanks again Yawmark....[mental note: download a highlighter]

IMN logo majestic logo threadwatch logo seochat tools logo