Adolf Liepelt wrote:
>
> Hi all,
>
> I want to use the reference of a bean declared by <jsp:useBean id="bean"
> .../> in my custom tag. Does anybody know how to get this reference with
> the correct type?

The <jsp:useBean> action places a reference to the bean in the specified
scope, or the page scope by default, using the name specified by the id
attribute.

So your custom action could look something like this:

  <foo:myAction name="bean" ... />

The name attribute specified the name of the bean you like to use,
and your custom action implementation can search for it in all scopes
using the methods of the PageContext class (always available to a
custom action).

If the custom action can deal with beans of different types, it can
use "if (theBean instanceof AClass)" tests to do different things
depending on the type of the bean, or use introspection to look for
required methods in the bean, etc. What's right here depends on what
the custom action is designed to do.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to