You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Mike.G" <hy...@gmail.com> on 2009/03/08 08:08:14 UTC

tomcat 6.0.18 issue with my customer Tag class

Hi, everyone,
I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07

I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
the configuration file like this:

<?xml version='1.0' encoding='utf-8'?>

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.core.AprLifecycleListener"
SSLEngine="on" />
   <Listener className="org.apache.catalina.core.JasperListener" />
   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
/>
  <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <GlobalNamingResources>
     <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

       </Host>
    </Engine>
  </Service>
</Server>


and I created the directory understand CATALINE_HOME/conf/Catalina/localhost
and create a ROOT.xml in there
like this:
<?xml version="1.0" encoding="utf-8"?>

<Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >

</Context>

when write a test index.jsp in /home/ghw/myjava, it works.


and when I try to write a Tag class in there, it will be report Error:

*type* Exception report

*message*

*description* *The server encountered an internal error () that prevented it
from fulfilling this request.*

*exception*

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 10 in the jsp file: /test.jsp
JavaScriptExampleTag cannot be resolved to a type
7:     </head>
8:     <body>
9:         <p>This is a simple test page </p>
10:         <my:message>
11:             This is a simple java alert message
12:         </my:message>
13:


An error occurred at line: 10 in the jsp file: /test.jsp
JavaScriptExampleTag cannot be resolved to a type
7:     </head>
8:     <body>
9:         <p>This is a simple test page </p>
10:         <my:message>
11:             This is a simple java alert message
12:         </my:message>
13:


An error occurred at line: 10 in the jsp file: /test.jsp
JavaScriptExampleTag cannot be resolved to a type
7:     </head>
8:     <body>
9:         <p>This is a simple test page </p>
10:         <my:message>
11:             This is a simple java alert message
12:         </my:message>
13:


Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)


here is my web.xml
    <taglib>
        <taglib-uri>
            /WEB-INF/tld/JavaScriptExampleTag.tld
        </taglib-uri>

        <taglib-location>
            /WEB-INF/tld/JavaScriptExampleTag.tld
        </taglib-location>
    </taglib>


and the tld file is like this:
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE taglib
        PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
        "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>JavaScriptExampleTag</short-name>
    <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
    <description>
        A simple tab library for the examples
    </description>

    <tag>
        <name>message</name>
        <tag-class>JavaScriptExampleTag</tag-class>
        <info>Display Alert Box</info>
    </tag>



</taglib>


and the Tag class like this:
import java.io.IOException;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class JavaScriptExampleTag extends BodyTagSupport {
    public int doEndTag() throws JspTagException {
        String ls_alert = "";

        try {
            BodyContent lbc_bodycurrent = getBodyContent();

            if ( lbc_bodycurrent != null ) {
                String ls_message = lbc_bodycurrent.getString();
                JavaScriptExample JS = new JavaScriptExample();

                ls_alert = JS.alert(ls_message.trim());

            }

            pageContext.getOut().write(ls_alert);

        } catch ( IOException e ) {
            throw new JspTagException("Error " + e.toString());
        }
        return EVAL_PAGE;
    }
}

and the Bean class is like this:
import java.io.Serializable;

public class JavaScriptExample implements Serializable {

    public JavaScriptExample() {

    }

    public String alert(Object aobj_data) {
        return( start_script + " alert(\" " +
                aobj_data.toString() + "\");" +
                end_script );
    }



    //private area
    private String start_script = "<script language=\"javascript\">";
    private String end_script = "</script>";



}


anyone can help me on this?

thanks very much


Mike
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Re: tomcat 6.0.18 issue with my customer Tag class

Posted by Ron McNulty <rm...@xtra.co.nz>.
Hi Mike

Your tag syntax is a bit unusual. I would have expected

       <my:message msg="This is a simple java alert message"/>

Then you put a variable msg in your tag class (with a getter & setter), and 
the JSP runtime will populate it for you.

Regards

Ron

----- Original Message ----- 
From: "Mike.G" <hy...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>; <p...@pidster.com>
Sent: Monday, March 09, 2009 2:45 PM
Subject: Re: tomcat 6.0.18 issue with my customer Tag class


> thanks very much.
>
> let me try again
>
> Mike
>
> 2009/3/8 Pid <p...@pidster.com>
>
>> Mike.G wrote:
>> > Hi, everyone,
>> > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 
>> > 1.6.0_07
>> >
>> > I configure  the localhost 's ROOT to my home directory 
>> > /home/ghw/myjava
>> > the configuration file like this:
>> >
>> > <?xml version='1.0' encoding='utf-8'?>
>> >
>> > <Server port="8005" shutdown="SHUTDOWN">
>> >
>> >   <Listener className="org.apache.catalina.core.AprLifecycleListener"
>> > SSLEngine="on" />
>> >    <Listener className="org.apache.catalina.core.JasperListener" />
>> >    <Listener
>> className="org.apache.catalina.mbeans.ServerLifecycleListener"
>> > />
>> >   <Listener
>> > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
>> />
>> >
>> >   <GlobalNamingResources>
>> >      <Resource name="UserDatabase" auth="Container"
>> >               type="org.apache.catalina.UserDatabase"
>> >               description="User database that can be updated and saved"
>> >
>> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>> >               pathname="conf/tomcat-users.xml" />
>> >   </GlobalNamingResources>
>> >
>> >   <Service name="Catalina">
>> >     <Connector port="8080" protocol="HTTP/1.1"
>> >                connectionTimeout="20000"
>> >                redirectPort="8443" />
>> >     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
>> >    <Engine name="Catalina" defaultHost="localhost">
>> >       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
>> >              resourceName="UserDatabase"/>
>> >       <Host name="localhost"  appBase="webapps"
>> >             unpackWARs="true" autoDeploy="true"
>> >             xmlValidation="false" xmlNamespaceAware="false">
>> >
>> >        </Host>
>> >     </Engine>
>> >   </Service>
>> > </Server>
>> >
>> >
>> > and I created the directory understand
>> CATALINE_HOME/conf/Catalina/localhost
>> > and create a ROOT.xml in there
>> > like this:
>> > <?xml version="1.0" encoding="utf-8"?>
>> >
>> > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
>> >
>> > </Context>
>> >
>> > when write a test index.jsp in /home/ghw/myjava, it works.
>> >
>> >
>> > and when I try to write a Tag class in there, it will be report Error:
>> >
>> > *type* Exception report
>> >
>> > *message*
>> >
>> > *description* *The server encountered an internal error () that 
>> > prevented
>> it
>> > from fulfilling this request.*
>> >
>> > *exception*
>> >
>> > org.apache.jasper.JasperException: Unable to compile class for JSP:
>> >
>> > An error occurred at line: 10 in the jsp file: /test.jsp
>> > JavaScriptExampleTag cannot be resolved to a type
>> > 7:     </head>
>> > 8:     <body>
>> > 9:         <p>This is a simple test page </p>
>> > 10:         <my:message>
>> > 11:             This is a simple java alert message
>> > 12:         </my:message>
>> > 13:
>> >
>> >
>> > An error occurred at line: 10 in the jsp file: /test.jsp
>> > JavaScriptExampleTag cannot be resolved to a type
>> > 7:     </head>
>> > 8:     <body>
>> > 9:         <p>This is a simple test page </p>
>> > 10:         <my:message>
>> > 11:             This is a simple java alert message
>> > 12:         </my:message>
>> > 13:
>> >
>> >
>> > An error occurred at line: 10 in the jsp file: /test.jsp
>> > JavaScriptExampleTag cannot be resolved to a type
>> > 7:     </head>
>> > 8:     <body>
>> > 9:         <p>This is a simple test page </p>
>> > 10:         <my:message>
>> > 11:             This is a simple java alert message
>> > 12:         </my:message>
>> > 13:
>> >
>> >
>> > Stacktrace:
>> >
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
>> >
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
>> >
>> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
>> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
>> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
>> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
>> >
>> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
>> >
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
>> >
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
>> >
>> >
>> > here is my web.xml
>> >     <taglib>
>> >         <taglib-uri>
>> >             /WEB-INF/tld/JavaScriptExampleTag.tld
>> >         </taglib-uri>
>> >
>> >         <taglib-location>
>> >             /WEB-INF/tld/JavaScriptExampleTag.tld
>> >         </taglib-location>
>> >     </taglib>
>> >
>> >
>> > and the tld file is like this:
>> > <?xml version="1.0" encoding="utf-8"?>
>> >
>> > <!DOCTYPE taglib
>> >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
>> >         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
>> >
>> > <taglib>
>> >     <tlib-version>1.0</tlib-version>
>> >     <jsp-version>1.2</jsp-version>
>> >     <short-name>JavaScriptExampleTag</short-name>
>> >     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
>> >     <description>
>> >         A simple tab library for the examples
>> >     </description>
>> >
>> >     <tag>
>> >         <name>message</name>
>> >         <tag-class>JavaScriptExampleTag</tag-class>
>> >         <info>Display Alert Box</info>
>> >     </tag>
>> >
>> >
>> >
>> > </taglib>
>> >
>> >
>> > and the Tag class like this:
>> > import java.io.IOException;
>> > import javax.servlet.jsp.*;
>> > import javax.servlet.jsp.tagext.*;
>> >
>> > public class JavaScriptExampleTag extends BodyTagSupport {
>> >     public int doEndTag() throws JspTagException {
>> >         String ls_alert = "";
>> >
>> >         try {
>> >             BodyContent lbc_bodycurrent = getBodyContent();
>> >
>> >             if ( lbc_bodycurrent != null ) {
>> >                 String ls_message = lbc_bodycurrent.getString();
>> >                 JavaScriptExample JS = new JavaScriptExample();
>> >
>> >                 ls_alert = JS.alert(ls_message.trim());
>> >
>> >             }
>> >
>> >             pageContext.getOut().write(ls_alert);
>> >
>> >         } catch ( IOException e ) {
>> >             throw new JspTagException("Error " + e.toString());
>> >         }
>> >         return EVAL_PAGE;
>> >     }
>> > }
>>
>> Put your tag class in a package, and make sure the tag class is in the
>> correct folder like so:
>>
>>  myapp/index.jsp
>>  myapp/WEB-INF/classes/com/myapp/YourTag.class
>>  myapp/WEB-INF/tld/YourTag.tld
>>
>> Adjust the tag class definition in the the TLD accordingly.
>>
>> p
>>
>>
>>
>> > and the Bean class is like this:
>> > import java.io.Serializable;
>> >
>> > public class JavaScriptExample implements Serializable {
>> >
>> >     public JavaScriptExample() {
>> >
>> >     }
>> >
>> >     public String alert(Object aobj_data) {
>> >         return( start_script + " alert(\" " +
>> >                 aobj_data.toString() + "\");" +
>> >                 end_script );
>> >     }
>> >
>> >
>> >
>> >     //private area
>> >     private String start_script = "<script language=\"javascript\">";
>> >     private String end_script = "</script>";
>> >
>> >
>> >
>> > }
>> >
>> >
>> > anyone can help me on this?
>> >
>> > thanks very much
>> >
>> >
>> > Mike
>> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Request

Posted by André Warnier <aw...@ice-sa.com>.
Please scroll down to the very bottom of this message.
Like all messages on this list, it contains an email address to 
"unsubscribe". Just send an email there.


lina.mao[XLsoft China/SHA] wrote:
> Hi,Sir:
> Please delete my e-mail address from users@tomcat.apache.org.
> I don't belong to it,and I also don't need all your e-mail.
> Please help it!
> Thanks,
> Lina 
> 
> 
> 2009-03-09 
> 
> 
> 
> Lina Mao
> Purchasing Department
> XLsoft China
> Tel:        +86-21-52387681-8012
> Mob.      +86-15821443266
> Fax:       +86-21-52387680
> Email:     Lina.mao@xlsoft.com.cn
> Website: www.xlsoft.com.cn
> Address:  Room 21J, Tower B, No.1118, Chang Shou Road, Shang hai (200042),China
>  
> 
> 
> 
> 发件人: Mike.G 
> 发送时间: 2009-03-09  09:49:25 
> 收件人: Tomcat Users List; p 
> 抄送: 
> 主题: Re: tomcat 6.0.18 issue with my customer Tag class 
>  
> thanks very much.
> let me try again
> Mike
> 2009/3/8 Pid <p...@pidster.com>
>> Mike.G wrote:
>>> Hi, everyone,
>>> I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
>>>
>>> I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
>>> the configuration file like this:
>>>
>>> <?xml version='1.0' encoding='utf-8'?>
>>>
>>> <Server port="8005" shutdown="SHUTDOWN">
>>>
>>>   <Listener className="org.apache.catalina.core.AprLifecycleListener"
>>> SSLEngine="on" />
>>>    <Listener className="org.apache.catalina.core.JasperListener" />
>>>    <Listener
>> className="org.apache.catalina.mbeans.ServerLifecycleListener"
>>> />
>>>   <Listener
>>> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
>> />
>>>   <GlobalNamingResources>
>>>      <Resource name="UserDatabase" auth="Container"
>>>               type="org.apache.catalina.UserDatabase"
>>>               description="User database that can be updated and saved"
>>>
>> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>>>               pathname="conf/tomcat-users.xml" />
>>>   </GlobalNamingResources>
>>>
>>>   <Service name="Catalina">
>>>     <Connector port="8080" protocol="HTTP/1.1"
>>>                connectionTimeout="20000"
>>>                redirectPort="8443" />
>>>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
>>>    <Engine name="Catalina" defaultHost="localhost">
>>>       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
>>>              resourceName="UserDatabase"/>
>>>       <Host name="localhost"  appBase="webapps"
>>>             unpackWARs="true" autoDeploy="true"
>>>             xmlValidation="false" xmlNamespaceAware="false">
>>>
>>>        </Host>
>>>     </Engine>
>>>   </Service>
>>> </Server>
>>>
>>>
>>> and I created the directory understand
>> CATALINE_HOME/conf/Catalina/localhost
>>> and create a ROOT.xml in there
>>> like this:
>>> <?xml version="1.0" encoding="utf-8"?>
>>>
>>> <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
>>>
>>> </Context>
>>>
>>> when write a test index.jsp in /home/ghw/myjava, it works.
>>>
>>>
>>> and when I try to write a Tag class in there, it will be report Error:
>>>
>>> *type* Exception report
>>>
>>> *message*
>>>
>>> *description* *The server encountered an internal error () that prevented
>> it
>>> from fulfilling this request.*
>>>
>>> *exception*
>>>
>>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>>
>>> An error occurred at line: 10 in the jsp file: /test.jsp
>>> JavaScriptExampleTag cannot be resolved to a type
>>> 7:     </head>
>>> 8:     <body>
>>> 9:         <p>This is a simple test page </p>
>>> 10:         <my:message>
>>> 11:             This is a simple java alert message
>>> 12:         </my:message>
>>> 13:
>>>
>>>
>>> An error occurred at line: 10 in the jsp file: /test.jsp
>>> JavaScriptExampleTag cannot be resolved to a type
>>> 7:     </head>
>>> 8:     <body>
>>> 9:         <p>This is a simple test page </p>
>>> 10:         <my:message>
>>> 11:             This is a simple java alert message
>>> 12:         </my:message>
>>> 13:
>>>
>>>
>>> An error occurred at line: 10 in the jsp file: /test.jsp
>>> JavaScriptExampleTag cannot be resolved to a type
>>> 7:     </head>
>>> 8:     <body>
>>> 9:         <p>This is a simple test page </p>
>>> 10:         <my:message>
>>> 11:             This is a simple java alert message
>>> 12:         </my:message>
>>> 13:
>>>
>>>
>>> Stacktrace:
>>>
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
>> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
>>>       org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
>>>       org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
>>>       org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
>>>
>> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
>>>       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
>>>
>>>
>>> here is my web.xml
>>>     <taglib>
>>>         <taglib-uri>
>>>             /WEB-INF/tld/JavaScriptExampleTag.tld
>>>         </taglib-uri>
>>>
>>>         <taglib-location>
>>>             /WEB-INF/tld/JavaScriptExampleTag.tld
>>>         </taglib-location>
>>>     </taglib>
>>>
>>>
>>> and the tld file is like this:
>>> <?xml version="1.0" encoding="utf-8"?>
>>>
>>> <!DOCTYPE taglib
>>>         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
>>>         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
>>>
>>> <taglib>
>>>     <tlib-version>1.0</tlib-version>
>>>     <jsp-version>1.2</jsp-version>
>>>     <short-name>JavaScriptExampleTag</short-name>
>>>     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
>>>     <description>
>>>         A simple tab library for the examples
>>>     </description>
>>>
>>>     <tag>
>>>         <name>message</name>
>>>         <tag-class>JavaScriptExampleTag</tag-class>
>>>         <info>Display Alert Box</info>
>>>     </tag>
>>>
>>>
>>>
>>> </taglib>
>>>
>>>
>>> and the Tag class like this:
>>> import java.io.IOException;
>>> import javax.servlet.jsp.*;
>>> import javax.servlet.jsp.tagext.*;
>>>
>>> public class JavaScriptExampleTag extends BodyTagSupport {
>>>     public int doEndTag() throws JspTagException {
>>>         String ls_alert = "";
>>>
>>>         try {
>>>             BodyContent lbc_bodycurrent = getBodyContent();
>>>
>>>             if ( lbc_bodycurrent != null ) {
>>>                 String ls_message = lbc_bodycurrent.getString();
>>>                 JavaScriptExample JS = new JavaScriptExample();
>>>
>>>                 ls_alert = JS.alert(ls_message.trim());
>>>
>>>             }
>>>
>>>             pageContext.getOut().write(ls_alert);
>>>
>>>         } catch ( IOException e ) {
>>>             throw new JspTagException("Error " + e.toString());
>>>         }
>>>         return EVAL_PAGE;
>>>     }
>>> }
>> Put your tag class in a package, and make sure the tag class is in the
>> correct folder like so:
>>
>>  myapp/index.jsp
>>  myapp/WEB-INF/classes/com/myapp/YourTag.class
>>  myapp/WEB-INF/tld/YourTag.tld
>>
>> Adjust the tag class definition in the the TLD accordingly.
>>
>> p
>>
>>
>>
>>> and the Bean class is like this:
>>> import java.io.Serializable;
>>>
>>> public class JavaScriptExample implements Serializable {
>>>
>>>     public JavaScriptExample() {
>>>
>>>     }
>>>
>>>     public String alert(Object aobj_data) {
>>>         return( start_script + " alert(\" " +
>>>                 aobj_data.toString() + "\");" +
>>>                 end_script );
>>>     }
>>>
>>>
>>>
>>>     //private area
>>>     private String start_script = "<script language=\"javascript\">";
>>>     private String end_script = "</script>";
>>>
>>>
>>>
>>> }
>>>
>>>
>>> anyone can help me on this?
>>>
>>> thanks very much
>>>
>>>
>>> Mike
>>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Request

Posted by "lina.mao[XLsoft China/SHA]" <li...@xlsoft.com.cn>.
Hi,Sir:
Please delete my e-mail address from users@tomcat.apache.org.
I don't belong to it,and I also don't need all your e-mail.
Please help it!
Thanks,
Lina 


2009-03-09 



Lina Mao
Purchasing Department
XLsoft China
Tel:        +86-21-52387681-8012
Mob.      +86-15821443266
Fax:       +86-21-52387680
Email:     Lina.mao@xlsoft.com.cn
Website: www.xlsoft.com.cn
Address:  Room 21J, Tower B, No.1118, Chang Shou Road, Shang hai (200042),China
 



发件人: Mike.G 
发送时间: 2009-03-09  09:49:25 
收件人: Tomcat Users List; p 
抄送: 
主题: Re: tomcat 6.0.18 issue with my customer Tag class 
 
thanks very much.
let me try again
Mike
2009/3/8 Pid <p...@pidster.com>
> Mike.G wrote:
> > Hi, everyone,
> > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
> >
> > I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
> > the configuration file like this:
> >
> > <?xml version='1.0' encoding='utf-8'?>
> >
> > <Server port="8005" shutdown="SHUTDOWN">
> >
> >   <Listener className="org.apache.catalina.core.AprLifecycleListener"
> > SSLEngine="on" />
> >    <Listener className="org.apache.catalina.core.JasperListener" />
> >    <Listener
> className="org.apache.catalina.mbeans.ServerLifecycleListener"
> > />
> >   <Listener
> > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
> />
> >
> >   <GlobalNamingResources>
> >      <Resource name="UserDatabase" auth="Container"
> >               type="org.apache.catalina.UserDatabase"
> >               description="User database that can be updated and saved"
> >
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> >               pathname="conf/tomcat-users.xml" />
> >   </GlobalNamingResources>
> >
> >   <Service name="Catalina">
> >     <Connector port="8080" protocol="HTTP/1.1"
> >                connectionTimeout="20000"
> >                redirectPort="8443" />
> >     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> >    <Engine name="Catalina" defaultHost="localhost">
> >       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> >              resourceName="UserDatabase"/>
> >       <Host name="localhost"  appBase="webapps"
> >             unpackWARs="true" autoDeploy="true"
> >             xmlValidation="false" xmlNamespaceAware="false">
> >
> >        </Host>
> >     </Engine>
> >   </Service>
> > </Server>
> >
> >
> > and I created the directory understand
> CATALINE_HOME/conf/Catalina/localhost
> > and create a ROOT.xml in there
> > like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> >
> > </Context>
> >
> > when write a test index.jsp in /home/ghw/myjava, it works.
> >
> >
> > and when I try to write a Tag class in there, it will be report Error:
> >
> > *type* Exception report
> >
> > *message*
> >
> > *description* *The server encountered an internal error () that prevented
> it
> > from fulfilling this request.*
> >
> > *exception*
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > Stacktrace:
> >
> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> >
> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> >
> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> >
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> >
> >
> > here is my web.xml
> >     <taglib>
> >         <taglib-uri>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-uri>
> >
> >         <taglib-location>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-location>
> >     </taglib>
> >
> >
> > and the tld file is like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <!DOCTYPE taglib
> >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
> >         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> >
> > <taglib>
> >     <tlib-version>1.0</tlib-version>
> >     <jsp-version>1.2</jsp-version>
> >     <short-name>JavaScriptExampleTag</short-name>
> >     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
> >     <description>
> >         A simple tab library for the examples
> >     </description>
> >
> >     <tag>
> >         <name>message</name>
> >         <tag-class>JavaScriptExampleTag</tag-class>
> >         <info>Display Alert Box</info>
> >     </tag>
> >
> >
> >
> > </taglib>
> >
> >
> > and the Tag class like this:
> > import java.io.IOException;
> > import javax.servlet.jsp.*;
> > import javax.servlet.jsp.tagext.*;
> >
> > public class JavaScriptExampleTag extends BodyTagSupport {
> >     public int doEndTag() throws JspTagException {
> >         String ls_alert = "";
> >
> >         try {
> >             BodyContent lbc_bodycurrent = getBodyContent();
> >
> >             if ( lbc_bodycurrent != null ) {
> >                 String ls_message = lbc_bodycurrent.getString();
> >                 JavaScriptExample JS = new JavaScriptExample();
> >
> >                 ls_alert = JS.alert(ls_message.trim());
> >
> >             }
> >
> >             pageContext.getOut().write(ls_alert);
> >
> >         } catch ( IOException e ) {
> >             throw new JspTagException("Error " + e.toString());
> >         }
> >         return EVAL_PAGE;
> >     }
> > }
>
> Put your tag class in a package, and make sure the tag class is in the
> correct folder like so:
>
>  myapp/index.jsp
>  myapp/WEB-INF/classes/com/myapp/YourTag.class
>  myapp/WEB-INF/tld/YourTag.tld
>
> Adjust the tag class definition in the the TLD accordingly.
>
> p
>
>
>
> > and the Bean class is like this:
> > import java.io.Serializable;
> >
> > public class JavaScriptExample implements Serializable {
> >
> >     public JavaScriptExample() {
> >
> >     }
> >
> >     public String alert(Object aobj_data) {
> >         return( start_script + " alert(\" " +
> >                 aobj_data.toString() + "\");" +
> >                 end_script );
> >     }
> >
> >
> >
> >     //private area
> >     private String start_script = "<script language=\"javascript\">";
> >     private String end_script = "</script>";
> >
> >
> >
> > }
> >
> >
> > anyone can help me on this?
> >
> > thanks very much
> >
> >
> > Mike
> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: tomcat 6.0.18 issue with my customer Tag class

Posted by "Mike.G" <hy...@gmail.com>.
thanks very much.

let me try again

Mike

2009/3/8 Pid <p...@pidster.com>

> Mike.G wrote:
> > Hi, everyone,
> > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
> >
> > I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
> > the configuration file like this:
> >
> > <?xml version='1.0' encoding='utf-8'?>
> >
> > <Server port="8005" shutdown="SHUTDOWN">
> >
> >   <Listener className="org.apache.catalina.core.AprLifecycleListener"
> > SSLEngine="on" />
> >    <Listener className="org.apache.catalina.core.JasperListener" />
> >    <Listener
> className="org.apache.catalina.mbeans.ServerLifecycleListener"
> > />
> >   <Listener
> > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
> />
> >
> >   <GlobalNamingResources>
> >      <Resource name="UserDatabase" auth="Container"
> >               type="org.apache.catalina.UserDatabase"
> >               description="User database that can be updated and saved"
> >
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> >               pathname="conf/tomcat-users.xml" />
> >   </GlobalNamingResources>
> >
> >   <Service name="Catalina">
> >     <Connector port="8080" protocol="HTTP/1.1"
> >                connectionTimeout="20000"
> >                redirectPort="8443" />
> >     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> >    <Engine name="Catalina" defaultHost="localhost">
> >       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> >              resourceName="UserDatabase"/>
> >       <Host name="localhost"  appBase="webapps"
> >             unpackWARs="true" autoDeploy="true"
> >             xmlValidation="false" xmlNamespaceAware="false">
> >
> >        </Host>
> >     </Engine>
> >   </Service>
> > </Server>
> >
> >
> > and I created the directory understand
> CATALINE_HOME/conf/Catalina/localhost
> > and create a ROOT.xml in there
> > like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> >
> > </Context>
> >
> > when write a test index.jsp in /home/ghw/myjava, it works.
> >
> >
> > and when I try to write a Tag class in there, it will be report Error:
> >
> > *type* Exception report
> >
> > *message*
> >
> > *description* *The server encountered an internal error () that prevented
> it
> > from fulfilling this request.*
> >
> > *exception*
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> >
> >
> > Stacktrace:
> >
> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> >
> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> >
> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> >       org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> >
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> >       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> >
> >
> > here is my web.xml
> >     <taglib>
> >         <taglib-uri>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-uri>
> >
> >         <taglib-location>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-location>
> >     </taglib>
> >
> >
> > and the tld file is like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <!DOCTYPE taglib
> >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
> >         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> >
> > <taglib>
> >     <tlib-version>1.0</tlib-version>
> >     <jsp-version>1.2</jsp-version>
> >     <short-name>JavaScriptExampleTag</short-name>
> >     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
> >     <description>
> >         A simple tab library for the examples
> >     </description>
> >
> >     <tag>
> >         <name>message</name>
> >         <tag-class>JavaScriptExampleTag</tag-class>
> >         <info>Display Alert Box</info>
> >     </tag>
> >
> >
> >
> > </taglib>
> >
> >
> > and the Tag class like this:
> > import java.io.IOException;
> > import javax.servlet.jsp.*;
> > import javax.servlet.jsp.tagext.*;
> >
> > public class JavaScriptExampleTag extends BodyTagSupport {
> >     public int doEndTag() throws JspTagException {
> >         String ls_alert = "";
> >
> >         try {
> >             BodyContent lbc_bodycurrent = getBodyContent();
> >
> >             if ( lbc_bodycurrent != null ) {
> >                 String ls_message = lbc_bodycurrent.getString();
> >                 JavaScriptExample JS = new JavaScriptExample();
> >
> >                 ls_alert = JS.alert(ls_message.trim());
> >
> >             }
> >
> >             pageContext.getOut().write(ls_alert);
> >
> >         } catch ( IOException e ) {
> >             throw new JspTagException("Error " + e.toString());
> >         }
> >         return EVAL_PAGE;
> >     }
> > }
>
> Put your tag class in a package, and make sure the tag class is in the
> correct folder like so:
>
>  myapp/index.jsp
>  myapp/WEB-INF/classes/com/myapp/YourTag.class
>  myapp/WEB-INF/tld/YourTag.tld
>
> Adjust the tag class definition in the the TLD accordingly.
>
> p
>
>
>
> > and the Bean class is like this:
> > import java.io.Serializable;
> >
> > public class JavaScriptExample implements Serializable {
> >
> >     public JavaScriptExample() {
> >
> >     }
> >
> >     public String alert(Object aobj_data) {
> >         return( start_script + " alert(\" " +
> >                 aobj_data.toString() + "\");" +
> >                 end_script );
> >     }
> >
> >
> >
> >     //private area
> >     private String start_script = "<script language=\"javascript\">";
> >     private String end_script = "</script>";
> >
> >
> >
> > }
> >
> >
> > anyone can help me on this?
> >
> > thanks very much
> >
> >
> > Mike
> >       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: tomcat 6.0.18 issue with my customer Tag class

Posted by "Mike.G" <hy...@gmail.com>.
thanks very much, let me try.

Mike

2009/3/9 Martin Gainty <mg...@hotmail.com>

>
> <!-- start of taglib declaration my is the reference to the taglib which
> the jsp uses to reference JavaScriptExampleTag-->
> <tag>
>  <name>my</name>
>  <tag-class>JavaScriptExampleTag</tag-class>
>  <info>Display Alert Box</info>
>     <attribute>
>      <name>message</name>
>      <required>true</required>
>      <description><![CDATA[Put some message to echo here]]></description>
>    </attribute>
>    <attribute>
>      <name>id</name>
>      <required>false</required>
>      <rtexprvalue>false</rtexprvalue>
>      <description><![CDATA[id for referencing element. For UI and form tags
> it will be used as HTML id attribute]]></description>
>    </attribute>
>    <attribute>
>    <attribute>
>      <name>name</name>
>      <required>true</required>
>      <rtexprvalue>false</rtexprvalue>
>      <description><![CDATA[..Name ..]]></description>
>    </attribute>
>    <attribute>
> ......
> </tag>
>
> <!-- at start of jsp put all of your taglib declarations so the prefix my
> associates my to the JavaScriptExampleTag.tld such as what you see below-->
>
> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <%@ taglib uri="/WEB-INF/tld/JavaScriptExampleTag.tld" prefix="my"
> name="my"%>
>
> i didnt see the 'message' attribute in your BodyTagSupports declared
> variables or an accessor e.g.
> public class JavaScriptExampleTag extends BodyTagSupport {
> ........
> //String storage allocation for message
>   public String message;
> //mutator
>    public void setMessage(String message) {
>        this.message = message;
>    }
> //accessor
>    public void getMessage() {
>
>       return this.message;
>
>    }
>
> .......
> }
>
>
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/jsp/tagext/TagInfo.html
> implement pidster's advice for everything else..
>
> Martin
> ______________________________________________
> Disclaimer and confidentiality note
> Everything in this e-mail and any attachments relates to the official
> business of Sender. This transmission is of a confidential nature and Sender
> does not endorse distribution to any party other than intended recipient.
> Sender does not necessarily endorse content contained within this
> transmission.
>
>
>
>
> > Date: Sun, 8 Mar 2009 14:20:09 +0000
> > From: p@pidster.com
> > To: users@tomcat.apache.org
> > Subject: Re: tomcat 6.0.18 issue with my customer Tag class
> >
> > Mike.G wrote:
> > > Hi, everyone,
> > > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is
> 1.6.0_07
> > >
> > > I configure  the localhost 's ROOT to my home directory
> /home/ghw/myjava
> > > the configuration file like this:
> > >
> > > <?xml version='1.0' encoding='utf-8'?>
> > >
> > > <Server port="8005" shutdown="SHUTDOWN">
> > >
> > >   <Listener className="org.apache.catalina.core.AprLifecycleListener"
> > > SSLEngine="on" />
> > >    <Listener className="org.apache.catalina.core.JasperListener" />
> > >    <Listener
> className="org.apache.catalina.mbeans.ServerLifecycleListener"
> > > />
> > >   <Listener
> > > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
> />
> > >
> > >   <GlobalNamingResources>
> > >      <Resource name="UserDatabase" auth="Container"
> > >               type="org.apache.catalina.UserDatabase"
> > >               description="User database that can be updated and saved"
> > >
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> > >               pathname="conf/tomcat-users.xml" />
> > >   </GlobalNamingResources>
> > >
> > >   <Service name="Catalina">
> > >     <Connector port="8080" protocol="HTTP/1.1"
> > >                connectionTimeout="20000"
> > >                redirectPort="8443" />
> > >     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> > >    <Engine name="Catalina" defaultHost="localhost">
> > >       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> > >              resourceName="UserDatabase"/>
> > >       <Host name="localhost"  appBase="webapps"
> > >             unpackWARs="true" autoDeploy="true"
> > >             xmlValidation="false" xmlNamespaceAware="false">
> > >
> > >        </Host>
> > >     </Engine>
> > >   </Service>
> > > </Server>
> > >
> > >
> > > and I created the directory understand
> CATALINE_HOME/conf/Catalina/localhost
> > > and create a ROOT.xml in there
> > > like this:
> > > <?xml version="1.0" encoding="utf-8"?>
> > >
> > > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> > >
> > > </Context>
> > >
> > > when write a test index.jsp in /home/ghw/myjava, it works.
> > >
> > >
> > > and when I try to write a Tag class in there, it will be report Error:
> > >
> > > *type* Exception report
> > >
> > > *message*
> > >
> > > *description* *The server encountered an internal error () that
> prevented it
> > > from fulfilling this request.*
> > >
> > > *exception*
> > >
> > > org.apache.jasper.JasperException: Unable to compile class for JSP:
> > >
> > > An error occurred at line: 10 in the jsp file: /test.jsp
> > > JavaScriptExampleTag cannot be resolved to a type
> > > 7:     </head>
> > > 8:     <body>
> > > 9:         <p>This is a simple test page </p>
> > > 10:         <my:message>
> > > 11:             This is a simple java alert message
> > > 12:         </my:message>
> > > 13:
> > >
> > >
> > > An error occurred at line: 10 in the jsp file: /test.jsp
> > > JavaScriptExampleTag cannot be resolved to a type
> > > 7:     </head>
> > > 8:     <body>
> > > 9:         <p>This is a simple test page </p>
> > > 10:         <my:message>
> > > 11:             This is a simple java alert message
> > > 12:         </my:message>
> > > 13:
> > >
> > >
> > > An error occurred at line: 10 in the jsp file: /test.jsp
> > > JavaScriptExampleTag cannot be resolved to a type
> > > 7:     </head>
> > > 8:     <body>
> > > 9:         <p>This is a simple test page </p>
> > > 10:         <my:message>
> > > 11:             This is a simple java alert message
> > > 12:         </my:message>
> > > 13:
> > >
> > >
> > > Stacktrace:
> > >
> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> > >
> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> > >
> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> > >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> > >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> > >     org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> > >
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> > >
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> > >
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> > >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> > >
> > >
> > > here is my web.xml
> > >     <taglib>
> > >         <taglib-uri>
> > >             /WEB-INF/tld/JavaScriptExampleTag.tld
> > >         </taglib-uri>
> > >
> > >         <taglib-location>
> > >             /WEB-INF/tld/JavaScriptExampleTag.tld
> > >         </taglib-location>
> > >     </taglib>
> > >
> > >
> > > and the tld file is like this:
> > > <?xml version="1.0" encoding="utf-8"?>
> > >
> > > <!DOCTYPE taglib
> > >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
> > >         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> > >
> > > <taglib>
> > >     <tlib-version>1.0</tlib-version>
> > >     <jsp-version>1.2</jsp-version>
> > >     <short-name>JavaScriptExampleTag</short-name>
> > >     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
> > >     <description>
> > >         A simple tab library for the examples
> > >     </description>
> > >
> > >     <tag>
> > >         <name>message</name>
> > >         <tag-class>JavaScriptExampleTag</tag-class>
> > >         <info>Display Alert Box</info>
> > >     </tag>
> > >
> > >
> > >
> > > </taglib>
> > >
> > >
> > > and the Tag class like this:
> > > import java.io.IOException;
> > > import javax.servlet.jsp.*;
> > > import javax.servlet.jsp.tagext.*;
> > >
> > > public class JavaScriptExampleTag extends BodyTagSupport {
> > >     public int doEndTag() throws JspTagException {
> > >         String ls_alert = "";
> > >
> > >         try {
> > >             BodyContent lbc_bodycurrent = getBodyContent();
> > >
> > >             if ( lbc_bodycurrent != null ) {
> > >                 String ls_message = lbc_bodycurrent.getString();
> > >                 JavaScriptExample JS = new JavaScriptExample();
> > >
> > >                 ls_alert = JS.alert(ls_message.trim());
> > >
> > >             }
> > >
> > >             pageContext.getOut().write(ls_alert);
> > >
> > >         } catch ( IOException e ) {
> > >             throw new JspTagException("Error " + e.toString());
> > >         }
> > >         return EVAL_PAGE;
> > >     }
> > > }
> >
> > Put your tag class in a package, and make sure the tag class is in the
> > correct folder like so:
> >
> >  myapp/index.jsp
> >  myapp/WEB-INF/classes/com/myapp/YourTag.class
> >  myapp/WEB-INF/tld/YourTag.tld
> >
> > Adjust the tag class definition in the the TLD accordingly.
> >
> > p
> >
> >
> >
> > > and the Bean class is like this:
> > > import java.io.Serializable;
> > >
> > > public class JavaScriptExample implements Serializable {
> > >
> > >     public JavaScriptExample() {
> > >
> > >     }
> > >
> > >     public String alert(Object aobj_data) {
> > >         return( start_script + " alert(\" " +
> > >                 aobj_data.toString() + "\");" +
> > >                 end_script );
> > >     }
> > >
> > >
> > >
> > >     //private area
> > >     private String start_script = "<script language=\"javascript\">";
> > >     private String end_script = "</script>";
> > >
> > >
> > >
> > > }
> > >
> > >
> > > anyone can help me on this?
> > >
> > > thanks very much
> > >
> > >
> > > Mike
> > >     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
> _________________________________________________________________
> Express your personality in color! Preview and select themes for Hotmail®.
>
> http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme
>

RE: tomcat 6.0.18 issue with my customer Tag class

Posted by Martin Gainty <mg...@hotmail.com>.
<!-- start of taglib declaration my is the reference to the taglib which the jsp uses to reference JavaScriptExampleTag-->
<tag>
 <name>my</name>
 <tag-class>JavaScriptExampleTag</tag-class>
 <info>Display Alert Box</info>
    <attribute>
      <name>message</name>
      <required>true</required>
      <description><![CDATA[Put some message to echo here]]></description>
    </attribute>
    <attribute>
      <name>id</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
      <description><![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description>
    </attribute>
    <attribute>
    <attribute>
      <name>name</name>
      <required>true</required>
      <rtexprvalue>false</rtexprvalue>
      <description><![CDATA[..Name ..]]></description>
    </attribute>
    <attribute>
......
</tag>

<!-- at start of jsp put all of your taglib declarations so the prefix my associates my to the JavaScriptExampleTag.tld such as what you see below-->

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tld/JavaScriptExampleTag.tld" prefix="my" name="my"%>

i didnt see the 'message' attribute in your BodyTagSupports declared variables or an accessor e.g.
public class JavaScriptExampleTag extends BodyTagSupport {
........
//String storage allocation for message 
   public String message;
//mutator
    public void setMessage(String message) {
        this.message = message;
    }
//accessor
    public void getMessage() {

       return this.message;

    }

.......
}

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/jsp/tagext/TagInfo.html
implement pidster's advice for everything else..

Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 




> Date: Sun, 8 Mar 2009 14:20:09 +0000
> From: p@pidster.com
> To: users@tomcat.apache.org
> Subject: Re: tomcat 6.0.18 issue with my customer Tag class
> 
> Mike.G wrote:
> > Hi, everyone,
> > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
> > 
> > I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
> > the configuration file like this:
> > 
> > <?xml version='1.0' encoding='utf-8'?>
> > 
> > <Server port="8005" shutdown="SHUTDOWN">
> > 
> >   <Listener className="org.apache.catalina.core.AprLifecycleListener"
> > SSLEngine="on" />
> >    <Listener className="org.apache.catalina.core.JasperListener" />
> >    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
> > />
> >   <Listener
> > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> > 
> >   <GlobalNamingResources>
> >      <Resource name="UserDatabase" auth="Container"
> >               type="org.apache.catalina.UserDatabase"
> >               description="User database that can be updated and saved"
> >               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> >               pathname="conf/tomcat-users.xml" />
> >   </GlobalNamingResources>
> > 
> >   <Service name="Catalina">
> >     <Connector port="8080" protocol="HTTP/1.1"
> >                connectionTimeout="20000"
> >                redirectPort="8443" />
> >     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> >    <Engine name="Catalina" defaultHost="localhost">
> >       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> >              resourceName="UserDatabase"/>
> >       <Host name="localhost"  appBase="webapps"
> >             unpackWARs="true" autoDeploy="true"
> >             xmlValidation="false" xmlNamespaceAware="false">
> > 
> >        </Host>
> >     </Engine>
> >   </Service>
> > </Server>
> > 
> > 
> > and I created the directory understand CATALINE_HOME/conf/Catalina/localhost
> > and create a ROOT.xml in there
> > like this:
> > <?xml version="1.0" encoding="utf-8"?>
> > 
> > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> > 
> > </Context>
> > 
> > when write a test index.jsp in /home/ghw/myjava, it works.
> > 
> > 
> > and when I try to write a Tag class in there, it will be report Error:
> > 
> > *type* Exception report
> > 
> > *message*
> > 
> > *description* *The server encountered an internal error () that prevented it
> > from fulfilling this request.*
> > 
> > *exception*
> > 
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> > 
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> > 
> > 
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> > 
> > 
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7:     </head>
> > 8:     <body>
> > 9:         <p>This is a simple test page </p>
> > 10:         <my:message>
> > 11:             This is a simple java alert message
> > 12:         </my:message>
> > 13:
> > 
> > 
> > Stacktrace:
> > 	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> > 	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> > 	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> > 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> > 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> > 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> > 	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> > 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> > 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> > 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> > 
> > 
> > here is my web.xml
> >     <taglib>
> >         <taglib-uri>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-uri>
> > 
> >         <taglib-location>
> >             /WEB-INF/tld/JavaScriptExampleTag.tld
> >         </taglib-location>
> >     </taglib>
> > 
> > 
> > and the tld file is like this:
> > <?xml version="1.0" encoding="utf-8"?>
> > 
> > <!DOCTYPE taglib
> >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
> >         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> > 
> > <taglib>
> >     <tlib-version>1.0</tlib-version>
> >     <jsp-version>1.2</jsp-version>
> >     <short-name>JavaScriptExampleTag</short-name>
> >     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
> >     <description>
> >         A simple tab library for the examples
> >     </description>
> > 
> >     <tag>
> >         <name>message</name>
> >         <tag-class>JavaScriptExampleTag</tag-class>
> >         <info>Display Alert Box</info>
> >     </tag>
> > 
> > 
> > 
> > </taglib>
> > 
> > 
> > and the Tag class like this:
> > import java.io.IOException;
> > import javax.servlet.jsp.*;
> > import javax.servlet.jsp.tagext.*;
> > 
> > public class JavaScriptExampleTag extends BodyTagSupport {
> >     public int doEndTag() throws JspTagException {
> >         String ls_alert = "";
> > 
> >         try {
> >             BodyContent lbc_bodycurrent = getBodyContent();
> > 
> >             if ( lbc_bodycurrent != null ) {
> >                 String ls_message = lbc_bodycurrent.getString();
> >                 JavaScriptExample JS = new JavaScriptExample();
> > 
> >                 ls_alert = JS.alert(ls_message.trim());
> > 
> >             }
> > 
> >             pageContext.getOut().write(ls_alert);
> > 
> >         } catch ( IOException e ) {
> >             throw new JspTagException("Error " + e.toString());
> >         }
> >         return EVAL_PAGE;
> >     }
> > }
> 
> Put your tag class in a package, and make sure the tag class is in the
> correct folder like so:
> 
>  myapp/index.jsp
>  myapp/WEB-INF/classes/com/myapp/YourTag.class
>  myapp/WEB-INF/tld/YourTag.tld
> 
> Adjust the tag class definition in the the TLD accordingly.
> 
> p
> 
> 
> 
> > and the Bean class is like this:
> > import java.io.Serializable;
> > 
> > public class JavaScriptExample implements Serializable {
> > 
> >     public JavaScriptExample() {
> > 
> >     }
> > 
> >     public String alert(Object aobj_data) {
> >         return( start_script + " alert(\" " +
> >                 aobj_data.toString() + "\");" +
> >                 end_script );
> >     }
> > 
> > 
> > 
> >     //private area
> >     private String start_script = "<script language=\"javascript\">";
> >     private String end_script = "</script>";
> > 
> > 
> > 
> > }
> > 
> > 
> > anyone can help me on this?
> > 
> > thanks very much
> > 
> > 
> > Mike
> > 	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
Express your personality in color! Preview and select themes for Hotmail®. 
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme

Re: tomcat 6.0.18 issue with my customer Tag class

Posted by Pid <p...@pidster.com>.
Mike.G wrote:
> Hi, everyone,
> I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
> 
> I configure  the localhost 's ROOT to my home directory /home/ghw/myjava
> the configuration file like this:
> 
> <?xml version='1.0' encoding='utf-8'?>
> 
> <Server port="8005" shutdown="SHUTDOWN">
> 
>   <Listener className="org.apache.catalina.core.AprLifecycleListener"
> SSLEngine="on" />
>    <Listener className="org.apache.catalina.core.JasperListener" />
>    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
> />
>   <Listener
> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
>   <GlobalNamingResources>
>      <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>   </GlobalNamingResources>
> 
>   <Service name="Catalina">
>     <Connector port="8080" protocol="HTTP/1.1"
>                connectionTimeout="20000"
>                redirectPort="8443" />
>     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
>    <Engine name="Catalina" defaultHost="localhost">
>       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
> 
>        </Host>
>     </Engine>
>   </Service>
> </Server>
> 
> 
> and I created the directory understand CATALINE_HOME/conf/Catalina/localhost
> and create a ROOT.xml in there
> like this:
> <?xml version="1.0" encoding="utf-8"?>
> 
> <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> 
> </Context>
> 
> when write a test index.jsp in /home/ghw/myjava, it works.
> 
> 
> and when I try to write a Tag class in there, it will be report Error:
> 
> *type* Exception report
> 
> *message*
> 
> *description* *The server encountered an internal error () that prevented it
> from fulfilling this request.*
> 
> *exception*
> 
> org.apache.jasper.JasperException: Unable to compile class for JSP:
> 
> An error occurred at line: 10 in the jsp file: /test.jsp
> JavaScriptExampleTag cannot be resolved to a type
> 7:     </head>
> 8:     <body>
> 9:         <p>This is a simple test page </p>
> 10:         <my:message>
> 11:             This is a simple java alert message
> 12:         </my:message>
> 13:
> 
> 
> An error occurred at line: 10 in the jsp file: /test.jsp
> JavaScriptExampleTag cannot be resolved to a type
> 7:     </head>
> 8:     <body>
> 9:         <p>This is a simple test page </p>
> 10:         <my:message>
> 11:             This is a simple java alert message
> 12:         </my:message>
> 13:
> 
> 
> An error occurred at line: 10 in the jsp file: /test.jsp
> JavaScriptExampleTag cannot be resolved to a type
> 7:     </head>
> 8:     <body>
> 9:         <p>This is a simple test page </p>
> 10:         <my:message>
> 11:             This is a simple java alert message
> 12:         </my:message>
> 13:
> 
> 
> Stacktrace:
> 	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> 	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> 	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> 	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> 
> 
> here is my web.xml
>     <taglib>
>         <taglib-uri>
>             /WEB-INF/tld/JavaScriptExampleTag.tld
>         </taglib-uri>
> 
>         <taglib-location>
>             /WEB-INF/tld/JavaScriptExampleTag.tld
>         </taglib-location>
>     </taglib>
> 
> 
> and the tld file is like this:
> <?xml version="1.0" encoding="utf-8"?>
> 
> <!DOCTYPE taglib
>         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
>         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> 
> <taglib>
>     <tlib-version>1.0</tlib-version>
>     <jsp-version>1.2</jsp-version>
>     <short-name>JavaScriptExampleTag</short-name>
>     <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
>     <description>
>         A simple tab library for the examples
>     </description>
> 
>     <tag>
>         <name>message</name>
>         <tag-class>JavaScriptExampleTag</tag-class>
>         <info>Display Alert Box</info>
>     </tag>
> 
> 
> 
> </taglib>
> 
> 
> and the Tag class like this:
> import java.io.IOException;
> import javax.servlet.jsp.*;
> import javax.servlet.jsp.tagext.*;
> 
> public class JavaScriptExampleTag extends BodyTagSupport {
>     public int doEndTag() throws JspTagException {
>         String ls_alert = "";
> 
>         try {
>             BodyContent lbc_bodycurrent = getBodyContent();
> 
>             if ( lbc_bodycurrent != null ) {
>                 String ls_message = lbc_bodycurrent.getString();
>                 JavaScriptExample JS = new JavaScriptExample();
> 
>                 ls_alert = JS.alert(ls_message.trim());
> 
>             }
> 
>             pageContext.getOut().write(ls_alert);
> 
>         } catch ( IOException e ) {
>             throw new JspTagException("Error " + e.toString());
>         }
>         return EVAL_PAGE;
>     }
> }

Put your tag class in a package, and make sure the tag class is in the
correct folder like so:

 myapp/index.jsp
 myapp/WEB-INF/classes/com/myapp/YourTag.class
 myapp/WEB-INF/tld/YourTag.tld

Adjust the tag class definition in the the TLD accordingly.

p



> and the Bean class is like this:
> import java.io.Serializable;
> 
> public class JavaScriptExample implements Serializable {
> 
>     public JavaScriptExample() {
> 
>     }
> 
>     public String alert(Object aobj_data) {
>         return( start_script + " alert(\" " +
>                 aobj_data.toString() + "\");" +
>                 end_script );
>     }
> 
> 
> 
>     //private area
>     private String start_script = "<script language=\"javascript\">";
>     private String end_script = "</script>";
> 
> 
> 
> }
> 
> 
> anyone can help me on this?
> 
> thanks very much
> 
> 
> Mike
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org