• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JSTL and EL - Long value cast to String

 
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.
 
Rancher
Posts: 4122
47
  • 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.
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!