You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Henri Yandell <ba...@generationjava.com> on 2003/04/16 22:23:52 UTC

jsp:useBean

Is it me, or is jsp:useBean singularly useless when used inside a
<c:forEach> loop to make a new object each time?

ie) I am looping around a result-set and creating objects. However
jsp:useBean only creates the first time, every other time it uses that
version [part of the design].

In JSP 2.0, I could probably hack it by including the loop-index in the
useBean id, but in 1.2 it's just not easy. Is there some kind of boolean
attribute to useBean that I don't know about that tells it to always make
a new bean each time?

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: jsp:useBean

Posted by Henri Yandell <ba...@generationjava.com>.


On Wed, 16 Apr 2003, Hans Bergsten wrote:

> Henri Yandell wrote:
> > Is it me, or is jsp:useBean singularly useless when used inside a
> > <c:forEach> loop to make a new object each time?
> >
> > ie) I am looping around a result-set and creating objects. However
> > jsp:useBean only creates the first time, every other time it uses that
> > version [part of the design].
> >
> > In JSP 2.0, I could probably hack it by including the loop-index in the
> > useBean id, but in 1.2 it's just not easy. Is there some kind of boolean
> > attribute to useBean that I don't know about that tells it to always make
> > a new bean each time?
>
> You can remove the bean with <c:remove> when you're done with it (e.g.
> at the end of the loop). This way <jsp:useBean> will not find it so it
> creates a new bean.

Thanks, that works nicely.

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: jsp:useBean

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
Henri Yandell wrote:
> Is it me, or is jsp:useBean singularly useless when used inside a
> <c:forEach> loop to make a new object each time?
> 
> ie) I am looping around a result-set and creating objects. However
> jsp:useBean only creates the first time, every other time it uses that
> version [part of the design].
> 
> In JSP 2.0, I could probably hack it by including the loop-index in the
> useBean id, but in 1.2 it's just not easy. Is there some kind of boolean
> attribute to useBean that I don't know about that tells it to always make
> a new bean each time?

You can remove the bean with <c:remove> when you're done with it (e.g.
at the end of the loop). This way <jsp:useBean> will not find it so it
creates a new bean.

Hans
-- 
Hans Bergsten                                <ha...@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org