8 Replies Latest reply on May 6, 2003 4:09 PM by 843835

    error in tablibs ..Any help on this please

    843835
      hi,
      I am getting the following error when i try to run the below code ..
      I put all the files in corresponding folders and i am getting the following error when i run Test.jsp
      Error: 500
      Location: /Test.jsp
      Internal Servlet Error:
      org.apache.jasper.compiler.CompileException: /usr/tomcat/webapps/test/Test.jsp(6,0) Unable to load class null
           at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:129)
           at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspParseEventListener.java:761)
           at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventListener.java:138)
           at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEventListener.java:911)
           at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:194)


      *****************************

      package examples;

      import java.io.*;

      import javax.servlet.jsp.*;
      import javax.servlet.jsp.tagext.*;

      /**
      * Given a URI, uses the servlet context to find out how large the
      * "real" file is in bytes.
      *
      * @author Simon Brown
      */
      public class SizeTag extends javax.servlet.jsp.tagext.TagSupport {

      /** the URI of the file */
      private String uri;

      /**
      * Performs the processing of this tag.
      */
      public int doStartTag() throws JspException {
      StringBuffer html = new StringBuffer();

      // ask the container (via the servlet context) for the
      // real path of a file pointed to by a URI
      String realPath = pageContext.getServletContext().getRealPath(uri);

      // we can now find out how large the file is
      File f = new File(realPath);
      long fileLength = f.length();

      // build up the HTML piece by piece ...
      html.append(fileLength);
      html.append(" bytes");

      // ... and write it
      try {
      pageContext.getOut().write(html.toString());
      } catch (IOException ioe) {
      throw new JspException(ioe.getMessage());
      }

      return EVAL_BODY_INCLUDE;
      }

      /**
      * Standard JavaBeans style property setter for the URI.
      *
      * @param s a String representing the URI
      */
      public void setUri(String s) {
      this.uri = s;
      }

      }

      ********************
      taglib.tld file:-

      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
      "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

      <taglib>
      <tlibversion>1.0</tlibversion>
      <jspversion>1.1</jspversion>
      <shortname>examples</shortname>
      <uri>http://123.123.142.156/test/taglib</uri>
      <info>An example tag library</info>

      <tag>
      <name>size</name>
      <tag-class>examples.SizeTag</tag-class>
      <info>Works out how large a file, pointed to by a URI, is in bytes</info>
      <attribute>
      <name>uri</name>
      <required>true</required>
      <rtexprvalue>false</rtexprvalue>
      </attribute>
      </tag>

      </taglib>
      ************************************
      web.xml file:

      <taglib>
      <taglib-uri>
      http://123.123.142.156/test/taglib
      <taglib-uri>
      <taglib-location>
      /WEB-INF/taglib.tld
      <taglib-location>
      </taglib>
      ********************
      Test.jsp File:


      <html>
      <head>
      <%@ taglib uri="http://123.123.142.156/test/taglib" prefix="examples" %>
      </head>

      <body>
      The file is <examples:size uri="index.html"/>.
      </body>
      </html>
      *********************

      Any help please ...

      thanks.
        • 1. Re: error in tablibs ..Any help on this please
          843835
          In web.xml, try changing the taglib-uri to "/WEB-INF/taglib.tld". then in your JSP, refer to the tag library as follows:
          <%@ taglib uri="/WEB-INF/taglib.tld" prefix="examples" %>
          • 2. Re: error in tablibs ..Any help on this please
            843835
            Hi Mark,
            I changed and now i am getting the following error :

            Error: 500
            Location: /development/TestTagLib.jsp
            Internal Servlet Error:

            org.apache.jasper.compiler.CompileException: /opt/software/tomcat/webapps/development/TestTagLib.jsp(2,0) Unable to open taglibrary http://63.169.156.100/development/taglib : Parse Error in the tag library descriptor: Illegal character at end of document, <.
                 at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:713)
                 at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:116)
                 at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215
            • 3. Re: error in tablibs ..Any help on this please
              843835
              Hi Mark,
              I changed and now i am getting the following error :

              Error: 500
              Location: /test/Test.jsp
              Internal Servlet Error:

              org.apache.jasper.compiler.CompileException: /opt/software/tomcat/webapps/development/Test.jsp(2,0) Unable to open taglibrary http://123.123.142.156/test/taglib : Parse Error in the tag library descriptor: Illegal character at end of document, <.
                   at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:713)
                   at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:116)
                   at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215
              • 4. Re: error in tablibs ..Any help on this please
                843835
                Check your TLD. It's not parsing correctly.
                • 5. Re: error in tablibs ..Any help on this please
                  843835
                  Sorry - you also need to change the URI in your JSP as mentioned in my previous post.
                  • 6. Re: error in tablibs ..Any help on this please
                    843835
                    Hi Yark,

                    Please help me .. Still i am getting first error only ...
                    Error: 500
                    Location: /development/Test.jsp
                    Internal Servlet Error:

                    org.apache.jasper.compiler.CompileException: /usr/tomcat/webapps/development/Test.jsp(5,12) Unable to load class null
                         at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:129)
                         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspParseEventListener.java:761)

                    Here is my code:

                    taglib.tld file:-

                    <?xml version="1.0" encoding="UTF-8" ?>

                    <!DOCTYPE taglib
                    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
                    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
                    <taglib>
                    <tlib-version>1.0</tlib-version>
                    <jsp-version>1.2</jsp-version>
                    <short-name>examples</short-name>
                    <uri>http://123.123.142.156/test/taglib</uri>
                    <display-name>taglib</display-name>
                    <description>An example tag library</description>
                    <tag>
                    <name>size</name>
                    <tag-class>examples.SizeTag</tag-class>
                    <body-content>JSP</body-content>
                    <description>Works out how large a file, pointed to by a URI, is in bytes</description>
                    <!-- Forte4J_TLDX: This comment contains code generation information. Do not delete.
                    <tldx>
                    <packagename>examples</packagename>
                    <extendsSupportClass>TRUE</extendsSupportClass>
                    <supportClass>BodyTagSupport</supportClass>
                    <implementsTryCatchFinally>FALSE</implementsTryCatchFinally>
                    <findparent>FALSE</findparent>
                    </tldx>
                    -->
                    <attribute>
                    <name>uri</name>
                    <required>true</required>
                    <rtexprvalue>false</rtexprvalue>
                    <type>String</type>
                    <!-- Forte4J_TLDX: This comment contains code generation information. Do not delete.
                    <tldx>
                    <IsReferenceID>FALSE</IsReferenceID>
                    <ReferencesTag>FALSE</ReferencesTag>
                    <ReferenceScope>Session</ReferenceScope>
                    <ReferencesTagReferentFirst>TRUE</ReferencesTagReferentFirst>
                    </tldx>
                    -->
                    </attribute>
                    </tag>
                    </taglib>
                    ******************
                    web.xml:

                    <taglib>
                    <taglib-uri>"/WEB-INF/taglib.tld"</taglib-uri>
                    <taglib-location>/WEB-INF/taglib.tld</taglib-location>
                    </taglib>
                    *******************
                    Test.jsp:

                    <html>
                    <head>
                    <%@ taglib uri="/WEB-INF/taglib.tld" prefix="examples" %>
                    </head>
                    <body>
                    The file is <examples:size uri="/jsp/index.html"/>.
                    </body>
                    </html>

                    thanks.
                    • 7. Re: error in tablibs ..Any help on this please
                      843835
                      examples.SizeTag in your classpath, I assume?
                      • 8. Re: error in tablibs ..Any help on this please
                        843835
                        Hi,

                        examples.SizeTag is under classpath ...
                        Still getting same error ...

                        Any help please ...

                        thanks.