Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL and EL - Long value cast to String

 
kashyapa kumarawadu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I'm trying to write a condition to jstl if tag,


Ledg is an object of ledger class and transactionID is a field of type long.

I found this error while runtime.



I tried to convert transactioID value to String by several ways. But not working.

String concatenation

Using custom tag

It also expects String type.
Any help? Thank you.
 
Dave Tolls
Ranch Hand
Posts: 2295
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your "user_ledgers" attribute being set?
Because it looks to me like EL is convinced its a collection of Strings.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never need to do any kind of casting in the EL.

Your error is on line 1. Inspect it very carefully.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside:
kashyapa kumarawadu wrote:Ledg is an object of ledger class

Then why is it not named ledger?

Needless abbreviations just make code harder to read.
 
kashyapa kumarawadu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all of you gays

As you all saying..

line 1 should be


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. Otherwise you were iterating over the string "user_ledgers", not he variable value.

But you should still use whole words for variable names. Bad naming makes for bad code.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!