compare « JSTL « JSP-Servlet Q&A

1. JSTL Exception while comparing a string

I have the next code in a JSTL file:

    <c:when test="${application.lodging eq 'F'}"><bean:message key="courseapplication.lodgingF"/></c:when>
    <c:when test="${application.lodging eq 'H'}"><bean:message key="courseapplication.lodgingH"/></c:when>
    <c:when test="${application.lodging ...

2. How to compare substring of a bean property in JSTL 1.0?

I have the following code in a jsp page (Struts backed):

<c:if test="${USERINFO.someproperty == 'test'}">
But what I would like to do is compare only a substring of someproperty, like e.g. if the ...

3. Is there an easy way to compare two strings in a jsp?

I am creating a drop down list of all languages, with the language used when creating other info in the page as the default selected in the list:

  <c:forEach ...

4. JSTL: String Comparison issue using c:When tag

I am facing problem when comparing 2 strings values using C:When tag
I am trying as follow

<c:when test="${dbUserName eq uName}">
dbUserName = “sohail”. It is fetching value from db column
uName = “test”. ...

5. JSTL string comparison always returns false

I am trying string comparison with

<c:if test="${dept eq 'account'}"></c:if>
But this always returns false. I check the dept variable had the value 'account'. I also tried like this
<c:if test="${dept == 'account'}"></c:if> ...

6. Java and JSTL/EL: How can I compare two integers stored as attributes?

I'm developing a web-app and I have three static variables in my class called AccountManagement that represent the three possible states that can be reached when clicking on a link in ...

7. How to compare parameters in JSTL

Dear I have list ID's from database and pass it through request in servlete class but i cant compare it to any number ithink maybe i have to convert it to ...

8. Expression Language/ Comparing two parameters (JSP)

I have a pretty simple question. If I'm comparing two parameters in a JSP page using c:if, which is correct?

<c:if test="${}==${}">
<c:if test="${}">

9. Comparing with enum value in JSTL

I have the follwoing enum in my backend java code:

public static enum CountryCodes implements EnumConstant {

10. How to compare the value after fetchin it from properties file in JSTL

I am using tag for localization please let me what am i doing wrong here <fmt:message key="some.key" var="var1" /> and checking condition like this <c:if test="${var1 == 1}" print some thing </c:if> the ...

11. JSP if statement comparing two variables not working

In JSP, I want to compare two variables If I do:

<c:set var="pagerTotDisp" value="9"/>
<c:if test="${pagerTotDisp > 8}">
  <span>pagerTotDisp above 8</span>
It displays "pagerTotDisp above 8" as expected
<c:set var="TotalPages" value="10"/>
<c:if test="${TotalPages > 2}">

12. How to write - jstl tag - comparing map key with struts formbean element

I need to retrieve list values from a map of type Map<String,List<HashMap<String, Object>>> in JSP based on a condition. The condition is to compare map key with formbean variable. Rightnow, I ...

13. string comparison with EL / JSTL

I've just started trying to incorporate EL/JSTL into my coding, so bear with me, as I had trouble finding documentation on my problem. I have a List stored as a session attribute under the name "dates". For example: List dates = new ArrayList(); dates.add("Aug 2005"); dates.add("Jul 2005"); session.setAttribute("dates", dates); I have a typical HTML select that dates is supposed to populate: ...

15. comparing values using JSTL

16. JSTL date comparison

Hey All, I have this requirement where i have group of records and each record has a date associated with it. I need to compare the date field with another standard date and depending on the outcome, i need to display some content. I am trying to use the following code Standard Content For some reason it is ...

17. jstl - compare date ignoring the day

18. Comparing variables using JSTL

21. comparing string to int in JSTL

22. JSTL String comparison problem

24. Comparing a String in JSTL When Tag

25. JSTL Comparison Syntax

Interesting case you've got here. If the EL expression is outside the attribute value of the tag, the normal back-slash quoting works fine. Apparently the triple-level of dual-purpose quoting when it's embedded inside a quoted attribute value adds a level of complexity to the parsing issue. Rather than dither around trying to find the right combination of bizarre escaping that'd make ...

26. JSTL comparing variables

27. Comparing values using JSTL

29. Compare Mysql date with current date

Hello, I am implementing an application for online auctions, it is part of my essay @ the university. I am using JSP/EL as basic tools. I want to compare the date that comes from mysql items table (start_date : the day that the auction starts) with the current date to check if the auction is started. How to do that with ...

30. JSTL -- Comparing two strings for equality

31. Compare java.math.BigDecimal in JSTL

Hi, I have 2 amounts , amt1 and amt2 which are java.math.BigDecimal, where i need to compare these amounts using JSTL in JSP , I have tried with both and like // do this // else // do this It is giving me an error saying Cannot ...