This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Check if a value is of type Long in JSTL  RSS feed

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I need to check in a JSP page that uses JSTL, to check if a value is of type Long. Is it possible to check using JSTL if a value is of some type ? How ?

TIA,
Ankit Chandrawat
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to know this? It's a very odd question.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use some thing like <c:if test="${item.class.name == 'Long')}">
What are you trying to achieve by checking the type of an object ?
 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I need to execute a <c:forEach> only when then a particular id is of type Long (or you can say a numeric value).
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like something that should be abstracted in the controller to me.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Chandrawat wrote:Actually I need to execute a <c:forEach> only when then a particular id is of type Long (or you can say a numeric value).

You can have your controller make sure that the value is of numeric type. Then in your view just check if the attribute exists, and if it exists, you can iterate over it as you know it would be numeric.
 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok..let me try, I am hopeful of getting some positive out of it. Thanks a lot for prompt response and other ideas.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!