You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by MindTerm <mi...@yahoo.com> on 2001/08/29 09:03:14 UTC

Custom Tag Can't Compile problem.

Dear all,

  I want to implement custom tag in jsp and I got the
following error :
 
  Environment:
--------------------------------------------------
  OS: Win 2k 
  Tomcat 4.0.7 beta 
  TagManager.class located at
webapps/myproject/WEB-INF/classes/TagManager.class
  
  web.xml:
--------------------------------------------------
   <taglib>
     <taglib-uri>/MYTAG</taglib-uri> 
    
<taglib-location>/WEB-INF/mytaglib.tld</taglib-location>

  </taglib> 

  mytaglib.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-jsptaglib_1_1.dtd">

<taglib>
  <!-- The version number of this tag library -->
  <tlibversion>1.0</tlibversion>

  <!-- The JSP specification version required to
function -->
  <jspversion>1.1</jspversion>

  <!-- The short name of this tag library -->
  <shortname></shortname>
  
  <!-- Public URI that uniquely identifies this
version of the tag library -->
 
<!--uri>http://jakarta.apache.org/taglibs/utilitytags</uri-->

  <!-- General information about this tag library -->
  <info>
    A simple tag library for the examples
  </info>
  
  <!-- subname -->
  <tag>
    <name>code</name>
    <tagclass>TagManager</tagclass>
    <!-- bodycontent
    JSP (default): the JSP container should evaluate
any body of the tag, but it can also be empty 
    tagdependent : any body of the tag would be
handled by the tag itself, but it can also be empty 
    empty        : body must be empty 
    -->
    <bodycontent>empty</bodycontent>
  </tag>  
</taglib>
  

my TagManager.java:
------------------------------------------------

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

public class TagManager extends TagSupport
{

  /**
   * Constructor
   */
  public TagManager( )
  {
    super();
  }

  public int doStartTag() throws JspException
  {
    try
    {
      pageContext.getOut().print("Hello.");
    }
    catch ( Exception ex )
    {
      throw new JspTagException( "SimpleTag: " +
ex.getMessage() );
    }
    return SKIP_BODY;
  }

  public int doEndTag()
  {
    return EVAL_PAGE;
  }

}



  Error:
  ------------------------------------------------
  Unable to compile class for JSP An error occurred at
line: 8 
in the jsp file: /jsp/project/ACC03.jsp 
Generated servlet error: 
C:\learning\tomcat4\work\localhost\tea\jsp\project\_0002fjsp_0002fproject_0002fACC03_jsp.java:90:
Class org.apache.jsp.TagManager not found. 
TagManager _jspx_th_ytag_code_0 = new TagManager(); 
^ An error occurred at line: 8 in the jsp file:
/jsp/project/ACC03.jsp 
Generated servlet error: 
C:\learning\tomcat4\work\localhost\tea\jsp\project\_0002fjsp_0002fproject_0002fACC03_jsp.java:90:
Class org.apache.jsp.TagManager not found. 
TagManager _jspx_th_ytag_code_0 = new TagManager(); 
^ 2 errors 

   the example in sun tutorial about cutsomer tag also
cause same error in my testing environment. 

   Thank for your help. 

M.T.

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Custom Tag Can't Compile problem.

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
This is not based on any knowledge of jasper, but do you get the exception
if you declare TagManager in a package?  My guess is that jasper uses the
fully qualified form of the tag name in declaring the tag in the jsp and
the fact that you dont use a package is upsetting it.

having said that - its a guess... 

hth
dim

On Wed, 29 Aug 2001, MindTerm wrote:

> Dear all,
> 
>   I want to implement custom tag in jsp and I got the
> following error :
>  
>   Environment:
> --------------------------------------------------
>   OS: Win 2k 
>   Tomcat 4.0.7 beta 
>   TagManager.class located at
> webapps/myproject/WEB-INF/classes/TagManager.class
>   
>   web.xml:
> --------------------------------------------------
>    <taglib>
>      <taglib-uri>/MYTAG</taglib-uri> 
>     
> <taglib-location>/WEB-INF/mytaglib.tld</taglib-location>
> 
>   </taglib> 
> 
>   mytaglib.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-jsptaglib_1_1.dtd">
> 
> <taglib>
>   <!-- The version number of this tag library -->
>   <tlibversion>1.0</tlibversion>
> 
>   <!-- The JSP specification version required to
> function -->
>   <jspversion>1.1</jspversion>
> 
>   <!-- The short name of this tag library -->
>   <shortname></shortname>
>   
>   <!-- Public URI that uniquely identifies this
> version of the tag library -->
>  
> <!--uri>http://jakarta.apache.org/taglibs/utilitytags</uri-->
> 
>   <!-- General information about this tag library -->
>   <info>
>     A simple tag library for the examples
>   </info>
>   
>   <!-- subname -->
>   <tag>
>     <name>code</name>
>     <tagclass>TagManager</tagclass>
>     <!-- bodycontent
>     JSP (default): the JSP container should evaluate
> any body of the tag, but it can also be empty 
>     tagdependent : any body of the tag would be
> handled by the tag itself, but it can also be empty 
>     empty        : body must be empty 
>     -->
>     <bodycontent>empty</bodycontent>
>   </tag>  
> </taglib>
>   
> 
> my TagManager.java:
> ------------------------------------------------
> 
> import javax.servlet.jsp.*;
> import javax.servlet.jsp.tagext.*;
> 
> public class TagManager extends TagSupport
> {
> 
>   /**
>    * Constructor
>    */
>   public TagManager( )
>   {
>     super();
>   }
> 
>   public int doStartTag() throws JspException
>   {
>     try
>     {
>       pageContext.getOut().print("Hello.");
>     }
>     catch ( Exception ex )
>     {
>       throw new JspTagException( "SimpleTag: " +
> ex.getMessage() );
>     }
>     return SKIP_BODY;
>   }
> 
>   public int doEndTag()
>   {
>     return EVAL_PAGE;
>   }
> 
> }
> 
> 
> 
>   Error:
>   ------------------------------------------------
>   Unable to compile class for JSP An error occurred at
> line: 8 
> in the jsp file: /jsp/project/ACC03.jsp 
> Generated servlet error: 
> C:\learning\tomcat4\work\localhost\tea\jsp\project\_0002fjsp_0002fproject_0002fACC03_jsp.java:90:
> Class org.apache.jsp.TagManager not found. 
> TagManager _jspx_th_ytag_code_0 = new TagManager(); 
> ^ An error occurred at line: 8 in the jsp file:
> /jsp/project/ACC03.jsp 
> Generated servlet error: 
> C:\learning\tomcat4\work\localhost\tea\jsp\project\_0002fjsp_0002fproject_0002fACC03_jsp.java:90:
> Class org.apache.jsp.TagManager not found. 
> TagManager _jspx_th_ytag_code_0 = new TagManager(); 
> ^ 2 errors 
> 
>    the example in sun tutorial about cutsomer tag also
> cause same error in my testing environment. 
> 
>    Thank for your help. 
> 
> M.T.
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
>