Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help!. Problem with logic:iterate and null checking

 
sudharsan, varadharajan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am new to struts. I am trying to use logic:iterate tag to iterate over a collection (ArrayList) which normally contains String objects. It could also contain NULL . I tried to check for NULL by using the logic resent
tag but it still blows up. Could some one please help me??
I am writing below the code and the exception:
<%
java.util.ArrayList list1 = new java.util.ArrayList();
list1.add("First");
list1.add("Second");
list1.add("Third");
list1.add("Fourth");
list1.add(null);
pageContext.setAttribute("list", list1, PageContext.PAGE_SCOPE);
%>
<jsp:useBean id="list" scope="page" class="java.util.ArrayList"/>
<logic:iterate id="item" name="list" indexId="index" >
<logic resent name="index" scope="page" />
<li><em><bean:write name="item"/></em> </li>
</logic resent>
</logic:iterate
EXCEPTION:
***********
X Servlet Error: Cannot find bean item in any scope: javax.servlet.jsp.JspException: Cannot find bean item in any scope
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:839)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
at _sudha_2D_iterate_jsp_17._jspService(_sudha_2D_iterate_jsp_17.java:181)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:312)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:487)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:678)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:331)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:117)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:151)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:323)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
 
sudharsan, varadharajan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I even tried checking on the "item" itself instead of "index".
It still blows up with an exception.
<%
java.util.ArrayList list1 = new java.util.ArrayList();
list1.add("First");
list1.add("Second");
list1.add("Third");
list1.add("Fourth");
list1.add("Fifth");
pageContext.setAttribute("list", list1, PageContext.PAGE_SCOPE);
%>
<jsp:useBean id="list" scope="page" class="java.util.ArrayList"/>
<logic:iterate id="item" name="list" indexId="index" >
<logic resent name="item" scope="page" />
<li><em><bean:write name="item"/></em> </li>
</logic resent>
</logic:iterate>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic