This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion in Expression Language

 
sweety singh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have confusion regarding the use of expression language,
if in servlet i write
String num="2";
request.setAttibute("mynum",num);

in jsp if i write
${mynum>3}------it will return false
it means using mynum as a key i get a value-"2"
which is a string ,so how can we compare "2">3
or is it it returns a integer value 2,if so it is ok
but in servlet String num="2";
then how can it return int value
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sweety,

The answer you are getting is right. Here is one statement that I caught from JSP specs, it goes like this: "If A or B is Byte, Short, Character, Integer, or Long coerce both A and B to Long and apply operator". Probably you might like to go through the secion JSP 2.3.5 to have a clear idea on how EL operations are performed.
 
sweety singh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply ,could you please explain in more detail
 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ, they say "in EL expression, the strings will be automatically converted into appropriate numeric or boolean value".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic