aspose file tools*
The moose likes Struts and the fly likes trying to get an object from a map in struts2 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 » Frameworks » Struts
Bookmark "trying to get an object from a map in struts2" Watch "trying to get an object from a map in struts2" New topic
Author

trying to get an object from a map in struts2

Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57

I have the following in my tag file, and I get an exception:





If i replace myMap[${groupName}] with myMap['Jobs'] it works perfectly. From the JSP that calls the tagfile i have




I also tried:



(this was someone elses solution from another forum with the same problem) but I still get the same error.

I have made sure EL is working, etc.

Is there any way to pass a variable that contains a string into my myMap object (I assume myMap is OGNL) ?

Thanks,

Billy[]



Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

Instead of this
<c:set var="myValue">${groupName}</c:set>
Can you try this
<s:push value="myValue">${groupName}</s:push>


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://struts.apache.org/2.1.8/docs/why-cant-i-use-jstl-style-el-expressions-in-struts-tags.html

Or use <s:set>. Either I or someonebody else wrote a thing about accessing JSP tag attributes, but I can't find it at the moment. In this case, if it's a string, it's just as easy this way.
Billy Vandory
Ranch Hand

Joined: Mar 23, 2010
Posts: 57
David Newton wrote:http://struts.apache.org/2.1.8/docs/why-cant-i-use-jstl-style-el-expressions-in-struts-tags.html

Or use <s:set>. Either I or someonebody else wrote a thing about accessing JSP tag attributes, but I can't find it at the moment. In this case, if it's a string, it's just as easy this way.


Thanks David and Ankit!


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trying to get an object from a map in struts2