Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in JSTL

 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

I tried the following just out of curiosity.
In JSTL we have "target" attribute in <c:set> tag. "c" is just a prefix used over here for example.This "target" accepts maps or beans as a value.

Map map = new Hashtable();
map.put("A","A");
map.put("B","B");
map.put("C","C");
map.put("D","D");
request.setAttribute("map",map);

then I used the following sentence
<c:set target="${map}" property="Hello" value="bye"/> The key value pair was successfully added to map. However I tired using "requestScope" object which is also a map but is an implict EL object

<c:set target="${requestScope}" property="Hello" value="bye"/>

However I got exception at runtime. Am I not allowed to make an entry in requestScope using <c:set> tag ?

Waiting for your suggestions.

Regards
Rohit.
[ November 30, 2005: Message edited by: Rohit Bhagwat ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
target attribute accepts an Object which should either be a Map with (name/value) pairs or a Bean with properties

To set a attribute in request scope you got to use different set of attributes available in <c:set> tag
<c:set var="Name" scope = "request" value="Rohit" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic