You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Huaxin <hx...@cs.ualberta.ca> on 2002/09/13 20:52:56 UTC

Re: AW: custom tag

I have an sort of irrelant question: when several .jar
file specifies the same class, how should we determine which
.jar file is responsible for the class currently?

Just as we see, too much time has been spent on similar situation
like this one below.

Thanks a lot!
Huaxin

On Thu, 13 Sep 2001, Stadie wrote:

> 	Sorry, you're right. Wasn't the servlet.jar, was the j2ee.jar !!
> 	Thanx a lot.
>
> > Looks like you have an old copy of "servlet.jar" in your Java extensions
> > directory ($JAVA_HOME/jre/lib/ext).  Don't do that.
> >
> > Craig
> >
> >
> > On Thu, 13 Sep 2001, Stadie wrote:
> >
> > > Date: Thu, 13 Sep 2001 19:39:06 +0200
> > > From: Stadie <P....@crossitmedia.com>
> > > Reply-To: tomcat-user@jakarta.apache.org
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: custom tag
> > >
> > > Hi,
> > > not easy to run custom tags with tomcat.
> > > I'm using jakarta-tomcat-4.0-rc1. By trying the example:
> > > http://localhost:8080/examples/jsp/simpletag/foo.jsp
> > > an error occurs.
> > > --- ERROR:
> > > A Servlet Exception Has Occurred
> > > org.apache.jasper.JasperException: Unable to compile class for JSP
> > >
> > > An error occurred at line: 15 in the jsp file: /jsp/simpletag/foo.jsp
> > >
> > > Generated servlet error:
> > > C:\tom40\work\localhost\examples\jsp\simpletag\foo$jsp.java:98: No
> > variable
> > > EVAL_BODY_AGAIN defined in interface javax.servlet.jsp.tagext.BodyTag.
> > >                           } while (_jspx_th_eg_foo_0.doAfterBody() ==
> > > javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN);
> > >
> > > --- END Error
> > >
> > > What is the problem, I'm trying around for several days just to run only
> > one
> > > custom tag. But nothing works.
> > >
> > > Thanx Peter
> > >
>


Re: AW: custom tag

Posted by Jim Cheesman <jc...@msl.es>.
At 09:34 PM 13/09/01, you wrote:
>On Fri, 13 Sep 2002, Huaxin wrote:
>
> > Date: Fri, 13 Sep 2002 12:52:56 -0600 (Mountain Daylight Time)
> > From: Huaxin <hx...@cs.ualberta.ca>
> > Reply-To: tomcat-user@jakarta.apache.org
> > To: tomcat-user@jakarta.apache.org
> > Subject: Re: AW: custom tag
> >
> > I have an sort of irrelant question: when several .jar
> > file specifies the same class, how should we determine which
> > .jar file is responsible for the class currently?

Usage:
<myTags:classLoaderCheck className="jim.tags.ClassLoaderCheckTag" />

I'll leave it as an exercise to the reader adding this to the tld, 
compiling etc...

package jim.tags;

import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
/**
  * Tag to check where a class was loaded from.
  *
  *@author     Jim Cheesman, Jon Skeet (from ant-user)
  *@created    September 14 2001
  */
public class ClassLoaderCheckTag extends BodyTagSupport {
   private String className;

   public void setClassName(String className) {
     this.className = className;
   }


   /**
    *  Outputs the where a given class was loaded from
    *
    *@return    SKIP_BODY
    */
   public int doAfterBody() {
     JspWriter out = getBodyContent().getEnclosingWriter();
     try {
       Class c = Class.forName(className);
       String classRes = "/" + className.replace('.', '/') + ".class";
       out.print("<b>Class:</b>" + className + "&nbsp;<b>URL:</b>" + 
c.getResource(classRes));
     }
     catch (Exception e) {
         // this is crap. A better way could certainly be found, but not at 
8:50am by me.
       System.err.println("Error processing " + className + ": " + e);
     }
     return SKIP_BODY;
   }
}


--

                           *   Jim Cheesman   *
             Trabajo: 
jchees@msl.es - (34)(91) 724 9200 x 2360
                 I am becoming 
increasingly worried that
                  there isn't enough anxiety in 
my life.



Re: AW: custom tag

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Fri, 13 Sep 2002, Huaxin wrote:

> Date: Fri, 13 Sep 2002 12:52:56 -0600 (Mountain Daylight Time)
> From: Huaxin <hx...@cs.ualberta.ca>
> Reply-To: tomcat-user@jakarta.apache.org
> To: tomcat-user@jakarta.apache.org
> Subject: Re: AW: custom tag
>
> I have an sort of irrelant question: when several .jar
> file specifies the same class, how should we determine which
> .jar file is responsible for the class currently?
>
> Just as we see, too much time has been spent on similar situation
> like this one below.
>

The answer depends on the class loading configuration of the version of
Tomcat you are using.  For Tomcat 4, see:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html

The problem here (servlet.jar or j2ee.jar as a system extension) is that
system extensions are effectively the highest priority -- so they get used
for the servlet API classes even though Tomcat has it's own current
version of servlet.jar in the right place.

> Thanks a lot!
> Huaxin
>

Craig


> On Thu, 13 Sep 2001, Stadie wrote:
>
> > 	Sorry, you're right. Wasn't the servlet.jar, was the j2ee.jar !!
> > 	Thanx a lot.
> >
> > > Looks like you have an old copy of "servlet.jar" in your Java extensions
> > > directory ($JAVA_HOME/jre/lib/ext).  Don't do that.
> > >
> > > Craig
> > >
> > >
> > > On Thu, 13 Sep 2001, Stadie wrote:
> > >
> > > > Date: Thu, 13 Sep 2001 19:39:06 +0200
> > > > From: Stadie <P....@crossitmedia.com>
> > > > Reply-To: tomcat-user@jakarta.apache.org
> > > > To: tomcat-user@jakarta.apache.org
> > > > Subject: custom tag
> > > >
> > > > Hi,
> > > > not easy to run custom tags with tomcat.
> > > > I'm using jakarta-tomcat-4.0-rc1. By trying the example:
> > > > http://localhost:8080/examples/jsp/simpletag/foo.jsp
> > > > an error occurs.
> > > > --- ERROR:
> > > > A Servlet Exception Has Occurred
> > > > org.apache.jasper.JasperException: Unable to compile class for JSP
> > > >
> > > > An error occurred at line: 15 in the jsp file: /jsp/simpletag/foo.jsp
> > > >
> > > > Generated servlet error:
> > > > C:\tom40\work\localhost\examples\jsp\simpletag\foo$jsp.java:98: No
> > > variable
> > > > EVAL_BODY_AGAIN defined in interface javax.servlet.jsp.tagext.BodyTag.
> > > >                           } while (_jspx_th_eg_foo_0.doAfterBody() ==
> > > > javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN);
> > > >
> > > > --- END Error
> > > >
> > > > What is the problem, I'm trying around for several days just to run only
> > > one
> > > > custom tag. But nothing works.
> > > >
> > > > Thanx Peter
> > > >
> >
>
>