aspose file tools*
The moose likes JSP and the fly likes Doubt in JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Doubt in JSTL" Watch "Doubt in JSTL" New topic
Author

Doubt in JSTL

Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
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

Joined: Nov 15, 2004
Posts: 1026
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" />


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in JSTL