Mike Campbell wrote:

>  I have an action class in which I've instantiated a bean, and called
> request.setAttribute("output", <my bean here>);Now, in my JSP, I'm
> trying to "get at" that bean with <bean:define...>.  I'm having a bit
> of trouble understanding the difference between the "id" and the
> "name" parameters.I can't use <bean:define name="output"
> type="the.correct.type">, since the "id" parameter is required.
> However, <bean:define id="output" type="the.correct.type"> gives me an
> error. (null pointer exception in the page context findAttribute()
> call).What DOES seem to work is <bean:define id="anythingIChoose"
> name="output" type="the.correct.type"> followed by <bean:write
> name="output" property="someBeanProperty">Also curiously (to me
> anyway), <bean:write name="anythingIChoose"
> property="someBeanProperty"> seems to work if preceeded by the above
> <bean:define...>.Can someone tell me what the id and name parameters
> do for bean:define, when all I'm looking to do is reference a bean on
> the request put there by the action class?  It appears that id,
> although required by the TLD, needn't be used, though it CAN be.
> What's the preferred pattern here?--
>

  Mike Campbell     Email: [EMAIL PROTECTED]
  S1 Corporation    voice: 678.421.4641
  Software Engineer fax: 678.421.4865
  R & D             web: http://www.s1.com/
  Black Knight
>

When you say you want to "get at" that bean, what is it exactly that you
wish to do?  For example, if all you want to do is render the value of
the bean (or a property of the bean) to the output page, you should use
<bean:write> instead of <bean:define>.

In <bean:define>, the "id" attribute tells you the name of the attribute
(and scripting variable) that will be *created* by this tag -- exactly
the same as the "id" attribute on the standard <jsp:useBean> tag works.
The "name" attribute, on the other hand, is the bean *from* which you
are copying the value to be created.

Craig McClanahan


Reply via email to