• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP string conversion  RSS feed

 
Brian Smith
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to compare a long to a literal in a JSTL "if" condition



the minRange property of pageBean returns a long but it keeps getting converted to a String. What am I doing wrong?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66149
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is your ">=1" outside of the EL expression?
 
Brian Smith
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it should be inside the curly braces?

like this

${pageBean.minRange>=1}

I am still learning and am just beginning with JSP, thanks for your help
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66149
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The ${} is used to enclose the entire EL expression -- it is not a "fetch" operator for scoped variables.

With your original syntax, the ">=1" was just a string literal in the JSP.
 
Brian Smith
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I get it. You pegged my misconception exactly. I was treating it like a fetch.

So something like this would also be valid as long as the datatypes were compatible.

<c:if test="${pageBean.maxRange <= pageBean.recordCount}">

Thanks again.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66149
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly! You catch on quick!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!