Arun Thomas wrote:
>
> Hello all!
>
> I know that the <jsp:useBean> tag is allowed to have a body.  My
> understanding from
> reading the spec is that the body will be executed if & only if the bean
> requested in
> the tag is created.  What does "created" mean in this instance?  Does it
> mean when a
> new bean must be loaded and instantiated, or does it apply if a preexisting
> bean is
> found in the session as well?
>
> I'm finding it hard to see the difference between:
>
>         <jsp:useBean id="fred" class="MyClass">
>                 <jsp:setProperty name="fred" property="*" />
>         </jsp:useBean>
>
> and
>
>         <jsp:useBean id="fred" class="MyClass" />
>         <jsp:setProperty name="fred" property="*" />
>
> Any clarification would be welcome.

In the first example, the setProperty action is only executed if there's no
bean in the specified scope with the name specified by the id attribute ("fred").
In the second example, setProperty is always executed when the page is processed.

Since you use the default scope (page), both examples turns out to work the same
since page scope beans are thrown away after the page is processed, so the
useBean action will always create a new one. But if you instead specified session
or application scope, there would be a difference.

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

===========================================================================
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