Be careful using <c:set> over <bean:define>.

The DefineTag creates both a scripting variable and a page scoped attribute, so you can use bean:define and then use that in any struts tag, jstl tag, or <% scriptlet %>, but not the same in reverse.

If you do c:set, only the scoped var is created, so doing <c:set var="myVal" value="test"/> and trying to use that in either logic:equal tag (for example) or a scriptlet, will fail.

The work around for that (when using c:set) would be to use <c:if test="${myVal == 'test'}>....</c:if>


Here's an example

test.jsp

1 <!--c:set var="val" value="test"/-->
2<bean:define id="val">
3test
4</bean:define>
5<c:out value="${val}"/><br/>
6<%=val%><br/>
7<logic:equal name="val" value="test">
8  <bean:write name="val"/>
9</logic:equal>


This runs fine, but if you uncomment line 1, and remove line 2 thru 4 and it blows up





-- James Mitchell Software Engineer / Open Source Evangelist Consulting / Mentoring / Freelance EdgeTech, Inc. 678.910.8017 AIM: jmitchtx Yahoo: jmitchtx MSN: [EMAIL PROTECTED]




----- Original Message ----- From: "Jeff Beal" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Friday, April 01, 2005 9:01 AM
Subject: Re: status messages in <html:link> tag



On Mar 31, 2005 1:54 PM, Fumo, Vince <[EMAIL PROTECTED]> wrote:
ok follow-up and I'm sure this one will take 2 seconds to answer..

part 1) is there a JSTL way to do the <bean:define>?

<c:set/>

--
Jeff Beal
Webmedx, Inc.
Pittsburgh, PA USA

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to