• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt in JSTL set tag

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a few doubts on c:set tag in JSTL

1) Can a <c:set> tag be used to assign an attribute List or Array as value
[i.e. <c:set var="list" value=some_array_or_list />

2) How does the container differentiate between an EL expression and a normal Java String
in the value attribute of the <c:set> tag

For instance,
<c:set var="name" value="${person.name}" />

Here how does the container knows that ${person.name} is to be evaluated
even though ${person.name} is a valid Java String

3) In page 445 of HFSJ under the "With Body" topic of <c:set> tag

we have
<c:set var="userLevel" scope="session">
Sheriff,Bartender,Cowgirl
</c:set>

should the values be taken as an "Array" Object or a "String" Object
with comma separated values


Could someone throw some light to get my doubts cleared

Thanks
Muthu
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.This version of <c:set> is only used to set scoped attributes.
2.EL will always treat '.' as the delimitter for:
{left-side}.{right-side}
where,
{left-side} - bean-name/map
{right-side} - property/key
3.'Sheriff,Bartender,Cowgirl' is the value of the attributte 'userLevel'
 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
my doubts still remain uncleared..

1) Can a <c:set> tag be used to assign an attribute List or Array as value
[i.e. <c:set var="list" value=some_array_or_list />

Of course, <c:set> is used to set scoped attributes..
but my doubt was whether the "var" version of <c:set>
can hold a list/array.

2) My second question was how does the conatiner differentiate
between a normal String and an EL expression..since the characters

"{","}","." can be part of a normal String too..

3)'Sheriff,Bartender,Cowgirl' is the value of the attributte 'userLevel'

But is it an "Array" or a "String with comma separated values"


muthu
 
Umakanth Godavarthy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.It can hold anything that is of type java.lang.Object, that is the law of 'scoped attributes', so it can definitely hold array/list object

2.The right side of '.' operator should be a valid java identifier. So it should follow the same rules like 'starting letter should be a letter, _ or $...etc'. if any attribute identifier contains say, '.' then you should use requestScope, sessionScope etc. implicit objects to retreive the value.

3.Its ofcourse a string.
reply
    Bookmark Topic Watch Topic
  • New Topic