Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to load tag handler class for tag

843836May 24 2004 — edited May 26 2004
Okay,

you can download my source code from http://www.ajimaji.com/ajimaji/tld.zip
I am trying to create a tag library that writes something on the page but I get the following error
org.apache.jasper.JasperException: /index.jsp(8,23) Unable to load tag handler class "org.extremecoding.locale.LocaleWriteTag" for tag "arash:localeWrite"
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:376)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:200)
	org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1318)
	org.apache.jasper.compiler.Parser.parseElements(Parser.java:1560)
	org.apache.jasper.compiler.Parser.parse(Parser.java:126)
	org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
	org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:461)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:430)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
	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:810)
Here is the java code
package org.extremecoding.locale;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.IterationTag;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;
import java.util.ResourceBundle;
import java.text.MessageFormat;
import java.util.Locale;
/**
 *  Generated tag class.
 */
public class LocaleWriteTag extends BodyTagSupport {
    private String _message="null";
    private String _propertyName;
    private String _locale;
    private String _resource;
    
    public LocaleWriteTag() {
        super();
    }
    
    public void otherDoStartTagOperations()  {
        try {
            JspWriter out = pageContext.getOut();
            out.println("something");
        } catch (java.io.IOException ex) {
            //throw ex;
            System.out.println("suck");
        }
        _message = "";
        try {
            ResourceBundle bundle = ResourceBundle.getBundle(this._resource, new Locale(this._locale));
            _message = bundle.getString( this._propertyName );
        } catch (java.util.MissingResourceException mre) {
            _message="...";
        }
    }
    
    
    public boolean theBodyShouldBeEvaluated()  {
        return true;
    }
    
    
    
    public void otherDoEndTagOperations()  {
    }
    
    public boolean shouldEvaluateRestOfPageAfterEndTag()  {
        return true;
    }
    
    
    
    
    public int doStartTag() throws JspException, JspException {
        otherDoStartTagOperations();
        if (theBodyShouldBeEvaluated()) {
            return EVAL_BODY_BUFFERED;
        } else {
            return SKIP_BODY;
        }
    }
    
    
    public int doEndTag() throws JspException, JspException {
        otherDoEndTagOperations();
        if (shouldEvaluateRestOfPageAfterEndTag()) {
            return EVAL_PAGE;
        } else {
            return SKIP_PAGE;
        }
    }
    
    public String getPropertyName() {
        return _propertyName;
    }
    
    public void setPropertyName(String value) {
        _propertyName = value;
    }
    
    public String getLocale() {
        return _locale;
    }
    
    public void setLocale(String value) {
        _locale = value;
    }
    
    public String getResource() {
        return _resource;
    }
    
    public void setResource(String value) {
        _resource = value;
    }
    
    public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
        
        bodyContent.writeOut(out);
        
        bodyContent.clearBody();
    }
    
    
    public void handleBodyContentException(Exception ex) throws JspException {
        throw new JspException("error in LocaleWriteTag: " + ex);
    }
    
    
    public int doAfterBody() throws JspException {
        try {
            BodyContent bodyContent = getBodyContent();
            JspWriter out = bodyContent.getEnclosingWriter();
            
            writeTagBodyContent(out, bodyContent);
        } catch (Exception ex) {
            handleBodyContentException(ex);
        }
        
        if (theBodyShouldBeEvaluatedAgain()) {
            return EVAL_BODY_AGAIN;
        } else {
            return SKIP_BODY;
        }
    }
    
    
    public boolean theBodyShouldBeEvaluatedAgain() {
        return false;
    }
    
}
Here is tld
<?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>arash</short-name>
    <uri>WEB-INF/arash.tld</uri>
    <display-name>arash</display-name>
    <small-icon></small-icon>
    <large-icon></large-icon>
    <description>A blank tag library template. 
    </description>
    <tag>
        <name>localeWrite</name>
        <tag-class>org.extremecoding.locale.LocaleWriteTag</tag-class>
        <body-content>JSP</body-content>
        <small-icon></small-icon>
        <large-icon></large-icon>
        <description></description>
        <attribute>
            <name>propertyName</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
            <type>String</type>
        </attribute>
        <attribute>
            <name>locale</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
            <type>String</type>
        </attribute>
        <attribute>
            <name>resource</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
            <type>String</type>
        </attribute>
        <example></example>
    </tag>
    
</taglib>
What is the problem? I tried to put the created jar file to the shared lib directory in tomcat, I got no results. any idea?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2004
Added on May 24 2004
10 comments
3,056 views