File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes if else in struts tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "if else in struts tags" Watch "if else in struts tags" New topic

if else in struts tags

Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
How can we implement the functionality of
if(){}else{} in struts tags???

"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
I recommend to use JSTL tags.

Ex: <c:if>
Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
Is there any Struts tags for this???
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The questions you are asking about Struts tags can all be answered by the Struts documentation.

There is a section for each of the various tag libraries in this link. For this question, look for the section entitled "Logic tags".

In answer to your specific question: Strus has an "if" (<logic:equals>) but no "else". That's why Vani and I both recommend using the JSTL tags over the Struts tags in this case.
[ September 11, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
With the logic tags you would have to use have to use two pairs of tags. You could use either a html:equal and html:notEqual pair or use a value="true" and value="false" pair. I agree that the JSTL tags are cleaner.

- Brent
I agree. Here's the link:
subject: if else in struts tags