• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayList<ArrayList>()  RSS feed

 
lokesh rajarathanam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello..


I'm storing database data in to an List record by record....

Ex: java code will be....


ArrayList al= new ArrayList();
for(int i=0;i<=4;i++)
{
ArrayList bl= new ArrayList();
bl.add("hi");
bl.add("hello");
bl.add("smile");
al.add(bl);
}



in jstl i need only second object i.e., al's of 2 position..


<c:forEach var="tes" items="${al[2]}">
<cut value="${tes[0]}" />
<cut value="${tes[1]}" />
</c:foreach>



im getting error.....

javax.el.PropertyNotFoundException: Property '0' not found on type java.lang.String
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
javax.el.BeanELResolver.property(BeanELResolver.java:267)
javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
org.apache.el.parser.AstValue.getValue(AstValue.java:97)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:928)
org.apache.jsp.jsp.baby.EditVaccine_jsp._jspx_meth_c_005fforEach_005f0(EditVaccine_jsp.java:469)
org.apache.jsp.jsp.baby.EditVaccine_jsp._jspService(EditVaccine_jsp.java:230)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
items="${al[2]} already represents an ArrayList inside "al". So if you loop through it, you'll get Strings, thus the exception.

(moving this thread to a more appropriate forum)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!