Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use if-else option in JSTL

Tags:

jsp

jstl

Is there an if-else tag available in JSTL?

like image 728
Srinivasan Avatar asked Jan 03 '11 19:01

Srinivasan


People also ask

How to do if else in JSP?

The if...else block starts out as an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between the Scriptlet tags.

What is the use of c if tag?

The < c:if > tag is used for testing the condition and it display the body content, if the expression evaluated is true. It is a simple conditional tag which is used for evaluating the body content, if the supplied condition is true.

Which of the following tags is used to conditions in JSP?

You can use <c:if> and <c:choose> tags to make conditional rendering in jsp using JSTL.

What is tag Library in JSP?

A tag library defines a collection of custom actions. The tags can be used directly by developers in manually coding a JSP page, or automatically by Java development tools. A tag library must be portable between different JSP container implementations.


1 Answers

Yes, but it's clunky as hell, e.g.

<c:choose>   <c:when test="${condition1}">     ...   </c:when>   <c:when test="${condition2}">     ...   </c:when>   <c:otherwise>     ...   </c:otherwise> </c:choose> 
like image 51
skaffman Avatar answered Oct 08 '22 00:10

skaffman