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 <[EMAIL PROTECTED]>
> > Reply-To: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > 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: 
[EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
                 I am becoming 
increasingly worried that
                  there isn't enough anxiety in 
my life.


Reply via email to