You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thomas Nybro Bolding <th...@danskebank.dk> on 2004/09/06 15:56:04 UTC

Vedr.: Problem when using TAGLIB in JSP

Assuming you are using 1.4 or higher your classes have to be in packages - 
see for instance this thread 
http://forum.java.sun.com/thread.jsp?thread=536889&forum=33&message=2596508

/Thomas





jlonc@gi-bon.sk
06-09-2004 15:24
Besvar venligst til "Tomcat Users List"

 
        Til:    tomcat-user@jakarta.apache.org
        cc: 
        Vedr.:  Problem when using TAGLIB in JSP



hi.

i have two classes:
"MyClass" and "test.MyClass" (they are totally the same and one of them is 

a member of package "test")

i use them as tagclasses (taglib.tld):
<?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.1</tlibversion>
  <jspversion>1.1</jspversion>
  <shortname></shortname>
  <tag>
    <name>my_tag</name>
    <tagclass>MyClass</tagclass>  <--- (for the second class it's 
"test.MyClass")
    <bodycontent>JSP</bodycontent>
    <info>
        test  tag
    </info>
    <attribute>
      <name>name</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
 </tag>
</taglib>


content of "web.xml":
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
   <display-name>test_MY</display-name>
        <taglib>
          <taglib-uri>tlt</taglib-uri> 
          <taglib-location>/WEB-INF/taglib.tld</taglib-location> 
        </taglib>
</web-app>


and the "index.jsp" is:
<%@ taglib uri="tlt" prefix="tlt" %>
<html>
        <head>
                <title>Organization</title>
        </head>
        <body bgcolor="white">
        <table border=2 cellspacing=3 cellpadding=3>
                <tr>
                        <td><b>Departments</b></td>
                </tr> 
                <tlt:my_tag>
                <tr>
                        <td><a href="list.jsp?deptName=">aaa</a></td>
                </tr>
                </tlt:my_tag>
        </table>
        </body>
</html>


variant with "test.MyClass" works without problems, but the packageless 
one generates this error/exception:

An error occurred at line: 11 in the jsp file: /index.jsp
Generated servlet error:
C:\Tomcat5\work\Catalina\localhost\test_my\org\apache\jsp\index_jsp.java:91: 

cannot resolve symbol
symbol  : class MyClass 
location: class org.apache.jsp.index_jsp
    MyClass _jspx_th_tlt_my_tag_0 = (MyClass) 
_jspx_tagPool_tlt_my_tag.get(MyClass.class);
    ^


An error occurred at line: 11 in the jsp file: /index.jsp
Generated servlet error:
C:\Tomcat5\work\Catalina\localhost\test_my\org\apache\jsp\index_jsp.java:91: 

cannot resolve symbol
symbol  : class MyClass 
location: class org.apache.jsp.index_jsp
    MyClass _jspx_th_tlt_my_tag_0 = (MyClass) 
_jspx_tagPool_tlt_my_tag.get(MyClass.class);
                                     ^


An error occurred at line: 11 in the jsp file: /index.jsp
Generated servlet error:
C:\Tomcat5\work\Catalina\localhost\test_my\org\apache\jsp\index_jsp.java:91: 

cannot resolve symbol
symbol  : class MyClass 
location: class org.apache.jsp.index_jsp
    MyClass _jspx_th_tlt_my_tag_0 = (MyClass) 
_jspx_tagPool_tlt_my_tag.get(MyClass.class);
 ^
3 errors



 
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
 
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
 org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
 
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


my tomcat's version: 5.0.28

i don't know what could be the problem...


any ideas?


Best regards,
Juraj Lonc



<FONT SIZE=1 FACE="Arial">_______________
Vi goer opmaerksom paa, at denne e-mail kan indeholde fortrolig information. Hvis du ved en fejltagelse modtager e-mailen, beder vi dig venligst informere afsender om fejlen ved at bruge svar-funktionen. Samtidig beder vi dig slette e-mailen i dit system uden at videresende eller kopiere den.
Selv om e-mailen og ethvert vedhaeftet bilag efter vores overbevisning er fri for virus og andre fejl, som kan paavirke computeren eller it-systemet, hvori den modtages og laeses, aabnes den paa modtagerens eget ansvar. Vi paatager os ikke noget ansvar for tab og skade, som er opstaaet i forbindelse med at modtage og bruge e-mailen.
_______________
Please note that this message may contain confidential information. If you have received this message by mistake, please inform the sender of the mistake by sending a reply, then delete the message from your system without making, distributing or retaining any copies of it.
Although we believe that the message and any attachments are free from viruses and other errors that might affect the computer or IT system where it is received and read, the recipient opens the message at his or her own risk. We assume no responsibility for any loss or damage arising from the receipt or use of this message.
</FONT>


Re: Vedr.: Problem when using TAGLIB in JSP

Posted by jl...@gi-bon.sk.
hi (again).

> 
> Assuming you are using 1.4 or higher your classes have to be in packages 
- 
> see for instance this thread 
> 
http://forum.java.sun.com/thread.jsp?thread=536889&forum=33&message=2596508
> 
> /Thomas
> 

you're right thomas, i am using 1.4,
but do know the reason, why sun (or whoever) decided to change it that 
way?
what's bad about packageless classes?

Best regards,
Juraj Lonc