C W Wilson wrote:

> Hi,
>
> I need to access a method in a bean, like such:
>
> ---
>
> <jsp:useBean id="beanTest" class="beans.bean"/>
> <%!
>         public boolean test() throws Exception {
>                 return beanTest.returnValue();
>         }
> %>
> <%
>
>         out.println(test());
> %>
>
> ---
>
> What do I have to do to access beanTest in test()?
>

Beans are like any other Java object -- you need an object reference to refer to
them in a method.  One way to do this would be to pass it as an argument, like
this:

<jsp:useBean id="beanTest" class="beans.bean" />
<%!
    public boolean test(beans.bean arg) throws Exception {
        return arg.returnValue();
    }
%>
<%
    out.println(test(beanTest));
%>

>
> Thanks,
> C W
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to