• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with <c:set> with a body syntax

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please consider the following code written by me while studying HFSJ topic JSTL:


It produces the required output:
aa
bb
cc

Now i wrote another code to produce the same output using the <c:set> with a body:



but it produces the following output:

[Ljava.lang.String;@738a71


Can anyone tell me why is it ot taking the value of "users" from the body?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The body is being evaluated and the resulting string is assigned to the variable. Using the value attribute and using the tag body are not interchangeable, and do not produce the same results.
 
Keith Flo
Ranch Hand
Posts: 128
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saima,

As usual .. Bear is right ... simply use value rather than the body content ... here's an example ... The issue is that c:set value uses the same type as the object retrieved by your EL expression ... in the body of the tag it calls toString() on the object retrieved ... at least that's my understanding ... see page 455 in K&B.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic