struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <>
Subject Re: Newbie help with Struts idiom: functional if/else tags
Date Mon, 14 Nov 2005 18:47:12 GMT
On 11/14/05, Mark S Petrovic <> wrote:
> Good day. I am new to Struts, and while I am coming up to speed, I'm
> still struggling with what are surely common idioms.
> In a JSP, I want to output, say, a <td> element body conditionally based
> on a given bean property.
> In pseudocode, I want
> if == true
> print <td> X </td>
> else
> print <td> Y </td>
> I examined the Struts Logic tags, but found no if/else construct, and
> I suspect there is a good reason for this.
> Does Struts culture encourage me to somehow move the solution into the
> bean itself, or is there a informed, stylish way to deal with this in
> the JSP?

You can easily simulate if/else (or even if - else if - else if) chains with
the JSTL <c:choose> tag, with nested <c:when> or <c:otherwise> tags. It's
similar in spirit to using the "switch" statement in Java or C.


Thank you.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message