• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL - test for string equals()

 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In jstl, how do we test if an attribute in scope which is of type 'String' is equal to another String value.

Suppose I have an attribute called 'class' in scope whose value is, say, 'TR1'. In scriptlets, I would do this -



In JSTL, the best I could come up with is as below



I searched the jstl function taglib and couldn't find an equals utility. Is there an easier way to do this, rather than setting up a scoped attribute for every string you want to test against?

Thanks,
Ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found one more way.



The above works.
Though this looks neater, I got this by trial and error.
I dint find any documentation on such usage.

ram.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramprasad madathil:
I dint find any documentation on such usage.


Do you not have a copy of the JSP Specification?
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do you not have a copy of the JSP Specification?


Sorry, apparently I searched in the wrong place.
I did look through the jstl spec and couldnt find anything.
I thought such stuff would find place in the jsl spec rather than the jsp spec.

ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it.
I should have searched under 'Expression Language' (JSP.2.3 General Syntax of the Expression Language) in the jsp spec.

Thanks,
Ram.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic