Skip to main content

Questions tagged [jstl]

JSTL (Jakarta Standard Tag Library) is a XML based standard tag library which offers tags to control the flow in a Facelets or JSP page, date/number formatting and internationalization facilities and several utility EL functions.

427 votes
8 answers
849k views

Evaluate empty or null JSTL c tags

How can I validate if a String is null or empty using the c tags of JSTL? I have a variable named var1 and I can display it, but I want to add a comparator to validate it. <c:out value="${var1}...
user338381's user avatar
  • 4,273
348 votes
7 answers
560k views

How to use if-else option in JSTL

Is there an if-else tag available in JSTL?
Srinivasan's user avatar
  • 11.8k
319 votes
13 answers
1.0m views

if...else within JSP or JSTL

I want to output some HTML code based on some condition in a JSP file. if (condition 1) { Some HTML code specific for condition 1 } else if (condition 2) { Some HTML code specific for ...
copenndthagen's user avatar
244 votes
4 answers
340k views

Check a collection size with JSTL

How can I check the size of a collection with JSTL? Something like: <c:if test="${companies.size() > 0}"> </c:if>
Sergio del Amo's user avatar
191 votes
23 answers
493k views

How to install JSTL? It fails with "The absolute uri cannot be resolved" or "Unable to find taglib" or NoClassDefFoundError or ClassCastException

I don't know what I've done incorrectly, but I can't include JSTL. I have jstl-1.2.jar, but unfortunately I get exception: org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/...
lukastymo's user avatar
  • 26.6k
177 votes
3 answers
101k views

JSTL in JSF2 Facelets... makes sense?

I would like to output a bit of Facelets code conditionally. For that purpose, the JSTL tags seem to work fine: <c:if test="${lpc.verbose}"> ... </c:if> However, I'm not sure if ...
Jan's user avatar
  • 9,607
170 votes
14 answers
458k views

How to do if-else in Thymeleaf?

What's the best way to do a simple if-else in Thymeleaf? I want to achieve in Thymeleaf the same effect as <c:choose> <c:when test="${potentially_complex_expression}"> <h2>...
Maciej Ziarko's user avatar
128 votes
5 answers
290k views

How to get a index value from foreach loop in jstl

I have a value set in the request object like the following, String[] categoriesList=null; categoriesList = engine.getCategoryNamesArray(); request.setAttribute("categoriesList", categoriesList ); ...
Java Questions's user avatar
125 votes
2 answers
176k views

Evaluate if list is empty JSTL

I've been trying to evaluate if this array list is empty or not but none of these have even compiled: <c:if test="${myObject.featuresList.size == 0 }"> <c:if test="${...
OscarRyz's user avatar
  • 198k
125 votes
2 answers
115k views

Loop through a Map with JSTL [duplicate]

I'm looking to have JSTL loop through a Map<String, String> and output the value of the key and it's value. For example I have a Map<String, String> which can have any number of entries, ...
Dean's user avatar
  • 1,261
121 votes
5 answers
242k views

JSP : JSTL's <c:out> tag

Writing a JSP page, what exactly does the <c:out> do? I've noticed that the following both has the same result: <p>The person's name is <c:out value="${person.name}" /></p> &...
Steve Kuo's user avatar
  • 62.6k
120 votes
7 answers
138k views

How do you get the length of a list in the JSF expression language?

How would I get the length of an ArrayList using a JSF EL expression? #{MyBean.somelist.length} does not work.
GBa's user avatar
  • 18.1k
110 votes
4 answers
265k views

Use JSTL forEach loop's varStatus as an ID

I want to use the count from the JSTL forEach loop, but my code doesnt seem to work. <c:forEach items="${loopableObject}" var="theObject" varStatus="theCount"> <div id="divIDNo${theCount}...
Mark W's user avatar
  • 5,944
108 votes
13 answers
125k views

Access Enum value using EL with JSTL

I have an Enum called Status defined as such: public enum Status { VALID("valid"), OLD("old"); private final String val; Status(String val) { this.val = val; } public ...
IaCoder's user avatar
  • 12.6k
107 votes
4 answers
271k views

How do I check two or more conditions in one <c:if>?

How do I check two conditions in one <c:if>? I tried this, but it raises an error: <c:if test="${ISAJAX == 0} && ${ISDATE == 0}">
Selva Kumar K.P.'s user avatar

15 30 50 per page
1
2 3 4 5
366