tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: iterate through the params
Date Wed, 07 Aug 2002 16:32:06 GMT
On Wed, 7 Aug 2002, Dave Anand wrote:

> How can I do this in JSTl.
> 
> <%@ page import="java.util.*" %>
> <dl><dt><b>Name</b>&nbsp;&nbsp;<b>Value</b>
> <% Enumeration enum = request.getParameterNames();
> String name = null; String value = null;
> while(enum.hasMoreElements()){
> name = (String)enum.nextElement();
> value = request.getParameter(name);%>
> <dt><b><%=name%>:</b>&nbsp;&nbsp;<%=value%><%}
%>
> </dl>
> 
> I tried the following
> 
> <c:forEach var="param" items="${param}">
>   <c:out value="${param}"/><br>
> </c:forEach>
> 
> the result
> 
> org.apache.taglibs.standard.lang.jstl.ImplicitObjects$5@527035
> org.apache.taglibs.standard.lang.jstl.ImplicitObjects$5@527035
> 
> The question is how can I access the name and value of "param".

You've got two problems here.  The first is that you've created a scoped
variable called 'param', but this scoped variable is hidden by implicit
object of the same name.  Instead of var="param", use a different name --
e.g., var="item".

Then, don't access the Map entry as a whole.  Write ${item.key} to get the
name of the parameter, and ${item.value} to get the value of the
parameter.  A full general example is

 <c:forEach var="item" items="${param}">
   <c:out value="${item.key}"/>=<c:out value="${item.value}"/>
 </c:forEach>

I believe the specific example you're looking for is just

 <c:forEach var="item" items="${param}">
   <c:out value="${item.value}"/>
 </c:forEach>

> ps. Since I am using my Hotmail account to send my out mail, I can not
> send it to taglibs-user@jakarta.apache.org

Looks like it got through succesfully.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message