File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes comparing string to int in JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "comparing string to int in JSTL" Watch "comparing string to int in JSTL" New topic

comparing string to int in JSTL

mark hunt

Joined: May 02, 2007
Posts: 8

I'm trying to compare two values with different type (String, int). Using scriplets, i would just covert one datatype to another and then compare them. How would i convert one to another in JSTL?. This is what i'm doing and it's not working (it never returns true):

divisionModel.divisionId is of type int. I tried using "==" operator as well but didn't work. Could someone please let me know what i'm doing wrong??. Thanks for your time and suggestion

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60059

Technically you are not comparing in the JSTL but the EL.

Check the EL section of the JSP Spec to see what conversions occur during comparisons.
[ June 14, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
mark hunt

Joined: May 02, 2007
Posts: 8
Thanks Bear. Problem solved.
I agree. Here's the link:
subject: comparing string to int in JSTL
Similar Threads
Sorting java.lang.objects
showing contents of arraylist using c:forEach
Help with sorting ArrayList using Comparator
I'm new to java and threads needs some help please...
List<? extends Comparable<? super T>> list, T key