• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL/EL - Is there any method that returns boolean for an element

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I pass List to JSP, is there any way that I can check if particular element (string) is present in list and it returns boolean accordingly?

If this is not possible then I have to create a Map<String,String> with entries like (X,1), (Y,1), (Z,1) .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Map is a good way to do this, except 1? Why 1? Why not a Boolean?
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I got it. but that boolean value is *ideally* not required if it was the case with Java ('Contains' method of List) .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could always write a custom tag or EL function. But I routinely use a Map for these types of things. In fact, I wrote about it long long ago...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!