Please help with iteration problem
I am trying to nest iterate tags. I've tried logic:iterate nested:iterate and c:forEach without success. Here's what I want to do. logic:iterate name=routes id=route type=RouteBean write stuff about the route. logic:iterate name=route property=segments id=segment type=SegmentBean write stuff about the segment /logic:iterate /logic:iterate routes points to a java.util.List of RouteBeans. Each RouteBean has a method, getSegments() that returns a java.util.List of SegmentBeans. I've looked at the documents and examples for the nested tag, but I don't see anything about this type of nesting. I don't have a monkey with a single bunch of bananas, instead I simply have a java.util.List of bunches, each of which has a java.util.List of bananas. I'd really appreciate any help ya'll can give me. I'm up for using any tag type (struts-logic, struts-nested, or JSTL). I'd just rather not fall back on scriptlets if I can help it. Thanks, Michael Bowman -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Please help with iteration problem
Thanks for the reply. I'm going to try it. As a matter of fact, I do have IDs that I'm using for the segments and objects contained within the segments. I want to use html:link tags within the loops to build links displaying various information about these objects. Do you know if I can use Struts tags inside of the JSTL tags? If the JSTL tags just put beans in some scope, will the Struts tags know any difference? On Thu, 26 Sep 2002 15:20:45 -0500 Eddie Bush [EMAIL PROTECTED] wrote: c:set var=routes value=${pageScope['routesKey']}/ - or - c:set var=routes value=${requestScope['routesKey']}/ - or - c:set var=routes value=${sessionScope['routesKey']}/ - or - c:set var=routes value=${applicationScope['routesKey']}/ Do I need the above if I put the java.util.List on the request object in my Struts Action class prior to forwarding to the JSP? c:forEach values=${routes} var=route !-- Iterate over routes -- Route ID: c:out value=${route.id}/br c:forEach values=${route.segments} var=segment !-- Iterate over segments -- Segment ID: c:out value=${route.id}/br /c:forEach /c:forEach (I don't know if your routes/segments have an id property - it's just an example) I'm reasonably certain this should work. I use basically the same construct to go over an ArrayList (exposed as a Collection) and it's nested ArrayList (again, exposed as a Collection). Michael Bowman wrote: I am trying to nest iterate tags. I've tried logic:iterate nested:iterate and c:forEach without success. Here's what I want to do. logic:iterate name=routes id=route type=RouteBean write stuff about the route. logic:iterate name=route property=segments id=segment type=SegmentBean write stuff about the segment /logic:iterate /logic:iterate routes points to a java.util.List of RouteBeans. Each RouteBean has a method, getSegments() that returns a java.util.List of SegmentBeans. I've looked at the documents and examples for the nested tag, but I don't see anything about this type of nesting. I don't have a monkey with a single bunch of bananas, instead I simply have a java.util.List of bunches, each of which has a java.util.List of bananas. I'd really appreciate any help ya'll can give me. I'm up for using any tag type (struts-logic, struts-nested, or JSTL). I'd just rather not fall back on scriptlets if I can help it. Thanks, Michael Bowman -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Please help with iteration problem
One further complication: I found that nested logic:iterate tags work on Tomcat 4.0.3, but not on Tomcat 4.1.10. Thats kind of weird. I don't see the struts-el tags listed on the Struts Resources/Contributor Taglibs page. Can you tell me where to find them? Thanks. On Thu, 26 Sep 2002 17:48:30 -0500 Eddie Bush [EMAIL PROTECTED] wrote: Find out about, download, install, and use the new contributed taglib struts-el. Michael Bowman wrote: Thanks for the reply. I'm going to try it. As a matter of fact, I do have IDs that I'm using for the segments and objects contained within the segments. I want to use html:link tags within the loops to build links displaying various information about these objects. Do you know if I can use Struts tags inside of the JSTL tags? If the JSTL tags just put beans in some scope, will the Struts tags know any difference? On Thu, 26 Sep 2002 15:20:45 -0500 Eddie Bush [EMAIL PROTECTED] wrote: c:set var=routes value=${pageScope['routesKey']}/ - or - c:set var=routes value=${requestScope['routesKey']}/ - or - c:set var=routes value=${sessionScope['routesKey']}/ - or - c:set var=routes value=${applicationScope['routesKey']}/ Do I need the above if I put the java.util.List on the request object in my Struts Action class prior to forwarding to the JSP? No. You could reference it as ${requestScope['key']} I believe. In fact ... *ponder* ... you could possible access it by ${key}. I think that may work too. I always go through the scope ... -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Please help with iteration problem
Correction, it seems that the version of Tomcat doesn't matter after all. A JSP with nested logic:iterate tags worked before, but not now. Maybe it was with an earlier version of Struts. Does anyone know if the behavior of logic:iterate changed with respect to nesting the tags between Struts 1.0 and Struts 1.1b? On Thu, 26 Sep 2002 19:02:19 -0400 Michael Bowman [EMAIL PROTECTED] wrote: One further complication: I found that nested logic:iterate tags work on Tomcat 4.0.3, but not on Tomcat 4.1.10. Thats kind of weird. I don't see the struts-el tags listed on the Struts Resources/Contributor Taglibs page. Can you tell me where to find them? Thanks. On Thu, 26 Sep 2002 17:48:30 -0500 Eddie Bush [EMAIL PROTECTED] wrote: Find out about, download, install, and use the new contributed taglib struts-el. Michael Bowman wrote: Thanks for the reply. I'm going to try it. As a matter of fact, I do have IDs that I'm using for the segments and objects contained within the segments. I want to use html:link tags within the loops to build links displaying various information about these objects. Do you know if I can use Struts tags inside of the JSTL tags? If the JSTL tags just put beans in some scope, will the Struts tags know any difference? On Thu, 26 Sep 2002 15:20:45 -0500 Eddie Bush [EMAIL PROTECTED] wrote: c:set var=routes value=${pageScope['routesKey']}/ - or - c:set var=routes value=${requestScope['routesKey']}/ - or - c:set var=routes value=${sessionScope['routesKey']}/ - or - c:set var=routes value=${applicationScope['routesKey']}/ Do I need the above if I put the java.util.List on the request object in my Struts Action class prior to forwarding to the JSP? No. You could reference it as ${requestScope['key']} I believe. In fact ... *ponder* ... you could possible access it by ${key}. I think that may work too. I always go through the scope ... -- Eddie Bush -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Is JSP compiler working right?
I have a JSP page with two iterator tags: %@ taglib uri='/WEB-INF/struts-logic.tld' prefix='logic' % logic:iterate name=routes id=route type=com.arinc.dce.routes.RouteVO logic:iterate name=route id=seg property=segments type=com.arinc.dce.routes.RouteSegment /logic:iterate /logic:iterate I'm populating the list of RouteVOs like this: List routeVOs = new ArrayList(routes.size()); for(Iterator i = routes.iterator(); i.hasNext(); ) { RouteBean r = (RouteBean) i.next(); RouteVO rvo = new RouteVO(r); routeVOs.add(rvo); } request.setAttribute(routes, routeVOs); I'm getting an exception that says: 2002-09-24 07:20:13 ApplicationDispatcher[/dce] Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP snip - Root Cause - org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 4 in the jsp file: /WEB-INF/jsp/multiRouteListContent.jsp Generated servlet error: [javac] Compiling 1 source file /usr/local/jakarta-tomcat-4.1.10/work/Standalone/localhost/dce/WEB-INF/jsp/multiRouteListContent_jsp.java:77: _jspx_seg_1 is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) com.arinc.dce.routes.RouteSegment _jspx_seg_1 = seg; When I look at the code that the JSP compiler generates I see: com.arinc.dce.routes.RouteSegment _jspx_seg_1 = null; and further down: /* logic:iterate */ com.arinc.dce.routes.RouteSegment _jspx_seg_1 = seg; Why is the servlet code generator doing this? I don't understant why it re-declares the variable when it hits the loop. Does anyone know how to get around this problem? I've attached the full text of the exception and the code generated by the JSP compiler. Any help would be appreciated. I've searched the mailing list to no avail. Thanks, Michael Bowman 2002-09-24 07:20:13 ApplicationDispatcher[/dce] Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:477) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:820) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:395) at org.apache.struts.taglib.template.GetTag.doStartTag(GetTag.java:191) at org.apache.jsp.mainTemplate_jsp._jspx_meth_template_get_3(mainTemplate_jsp.java:174) at org.apache.jsp.mainTemplate_jsp._jspService(mainTemplate_jsp.java:81) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:202) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:820) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:395) at org.apache.struts.taglib.template.InsertTag.doEndTag(InsertTag.java:155) at org.apache.jsp.multiRouteList_jsp._jspx_meth_template_insert_0(multiRouteList_jsp.java:112) at org.apache.jsp.multiRouteList_jsp._jspService(multiRouteList_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:202) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853