Title: JSP-INTEREST Digest - 23 Dec 2001 to 24 Dec 2001 (#2001-367)
Hi, Puray
 
Tomcat includes all classes located in web-inf/classes and all jars located in web-inf/lib into CLASSPATH available to your tag handler.
So, you ccan just add
 
import somepackage.SomeBean;
 
into your tag handler.
 
For examle, in JSP you declare bean as
 
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />
 
In tag handler the code will be next:
 
import dates.JspCalendar;
 
 
 
JspCalendar clock = (JspCalendar)   pageContext.getAttribute("clock", PageContext.PAGE_SCOPE);
 if ( clock == null ) {
  try {
      clock = (JspCalendar) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "dates.JspCalendar");
  } catch (ClassNotFoundException exc) {
          throw new InstantiationException(exc.getMessage());
  } catch (Exception exc) {
           throw new ServletException (" Cannot create bean of class "+"dates.JspCalendar", exc);
  }
  pageContext.setAttribute("clock", clock, PageContext.PAGE_SCOPE);
}
 Regards,
  Yuri
----- Original Message -----
From: Purav
Sent: Tuesday, December 25, 2001 9:12 AM
Subject: Accessing Beans from TagLibs

Hello,

 

I am using Tomcat 4.

I want to instantiate my Beans in my taglibs.

The Beans are located in web-inf/classes directory and taglibs are located in web-inf/lib directory

In JSP page I can use the jsp:useBean tag, but in my Taglib , how do I instantiate the bean. They are in a different directory�

Please Help

 

 

Purav

 

Reply via email to