You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Alexander Panzhin <wh...@mail333.com> on 2005/01/30 02:29:53 UTC

core:set - to java.util.Map????

Have a problem. Correct me if I'm wrong.

According to JSTL docs c:set should be able to set properties not only 
to beans but to Maps too.

Sample JSP code:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
java.util.HashMap map = new java.util.HashMap();
request.setAttribute("map", map);
%>
<c:set target="map" property="id" value=${something}/>

- This code throws exception " &lt;set&gt; invalid property "id" ".
Is this behavour correct?



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Re: core:set - to java.util.Map????

Posted by Martin Cooper <mf...@gmail.com>.
There are two problems with your example, both in the use of <c:set>.
You should have this:

  <c:set target="${map}" property="id" value="${something}"/>

That is, the value of 'target' needs to be the map itself, not the
name of the map; and you need to quote the value of the 'value'
attribute.

--
Martin Cooper


On Sun, 30 Jan 2005 03:29:53 +0200, Alexander Panzhin
<wh...@mail333.com> wrote:
> Have a problem. Correct me if I'm wrong.
> 
> According to JSTL docs c:set should be able to set properties not only
> to beans but to Maps too.
> 
> Sample JSP code:
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> <%
> java.util.HashMap map = new java.util.HashMap();
> request.setAttribute("map", map);
> %>
> <c:set target="map" property="id" value=${something}/>
> 
> - This code throws exception " &lt;set&gt; invalid property "id" ".
> Is this behavour correct?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org