Is there more to add than <%@ taglib uri="http://java.sun.com/jsp/jstl/core";
prefix="c" %>
 in my jsp page?

Eric


> Sounds like you didn't add JSTL to your application (that's why the JSTL
> expression isn't being evaluated).
>
> L.
>
> Eric Plante wrote:
> > Hi,
> >
> > Wendy, I tried:
> >
> > <c:forEach items="${PandoraForm.motTreeMap}" var="mot" >
> >     <c:out value="${mot.key}" />
> > </c:forEach>
> >
> > That's a test to output every key in the Map which contain 10 items.
> >
> > the tags are recognized but what's output is ${mot.key} once litteraly,
the
> > strings aren't recognized as data. I tried without the c:out but the
reszult
> > is the same.
> >
> >
> >
> >
> >>So your form has two Maps that are keyed alike?  I don't think you need
a
> >>custom tag (or Struts tags) at all. This iterates over a treeMap and
uses
> >>the key of each 'obj' as the key into a hashMap:
> >>
> >><c:forEach items="${treeMap}" var="obj" >
> >>  ${hashMap[obj.key]}
> >></c:forEach>
> >>
> >>That's with the Maps in request scope... if they're coming from the form
> >>bean, it would be items="${formBeanName.treeMap}" (assuming there is a
> >>getTreeMap method on your form bean.)
> >>
> >>The above also assumes JSTL 1.1.  If you're using JSTL 1.0 you'd need a
> >><c:out value="..." /> in the
> >>middle rather than just the expression.
> >>
> >>Here's the JSP I was using to play with this:
> >><%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
> >>
> >><%
> >>  java.util.TreeMap treeMap = new java.util.TreeMap();
> >>  treeMap.put( "key1", "value1" );
> >>  treeMap.put( "key2", "value2" );
> >>  request.setAttribute( "treeMap", treeMap );
> >>
> >>  java.util.HashMap hashMap = new java.util.HashMap();
> >>  hashMap.put( "value1", "description1" );
> >>  hashMap.put( "value2", "description2" );
> >>  hashMap.put( "key1",   "descByKey1" );
> >>  hashMap.put( "key2",   "descByKey2" );
> >>  request.setAttribute( "hashMap", hashMap );
> >>%>
> >>
> >>
> >><c:forEach items="${treeMap}" var="obj" >
> >>  ${hashMap[obj.value]}
> >></c:forEach>
> >>
> >><hr/>
> >>
> >><c:forEach items="${treeMap}" var="obj" >
> >>  ${hashMap[obj.key]}
> >></c:forEach>
> >>
> >>If you need help adding JSTL to your webapp, just ask.  (We need to know
> >>what version of the Servlet specification you're working with-- Servlet
> >
> > 2.4
> >
> >>(Tomcat 5.x) or something else?)
> >>
> >>HTH,
> >>-- 
> >>Wendy Smoak
> >>
> >>
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to