I don't think u r proceeding the right way.. When u removed property what has happened is u have eliminated the getCountries method call.. and thus u r able to see ur 3rd print statement. U need to have the property cauz the collection u need is an attribute of the DropDownCollections class, not the DropDownCollections class itself..(which is why its saying Cannot create iterator for DropDownCollections)..
Internally it creates an iterator out of the collection returned which its not able to create cauz there is no collection returned at all.. I doubt ur new LabelValueBean is throwing an error. Please do remove the exception handling from ur class.. -----Original Message----- From: sriram [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 3:21 PM To: 'Struts Users Mailing List' Subject: RE: drop-down list help Swaroop, I have made a change to <bean:define>. I removed 'property' --> (If not specified, the bean identified by name is given a new reference identified by id.) Then my println statements are working till Step 3. So, I presume the previous problem is solved. There's some problem now with <html:select>..... Trying to debug that: 15:23:26,419 ERROR [Engine] ApplicationDispatcher[/mobilemail_1_0] Servlet.servi ce() for servlet jsp threw exception org.apache.jasper.JasperException: Cannot create iterator for [EMAIL PROTECTED] Probably I need to use <html:optionsCollection> instead of <html:options> Sriram -----Original Message----- From: Swaroop George [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 3:12 PM To: Struts Users Mailing List Subject: RE: drop-down list help Yes I know that there is something wrong in bean:define. As the next step remove the try {} catch{} block in the getCountries method. Let it show up where exactly its failing.. -----Original Message----- From: sriram [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 3:00 PM To: 'Struts Users Mailing List' Subject: RE: drop-down list help :-( Same error! I modified the function as follows: public Collection getCountries() { ArrayList countries = new ArrayList(); try{ countries.add(new LabelValueBean("Australia", "1000")); countries.add(new LabelValueBean("New Zealand", "1001")); countries.add(new LabelValueBean("India", "1003")); } catch (Exception ex) { System.out.println(".............exception"); ex.printStackTrace(); } return countries; } In my jsp page, I have given println statements to trace out where exactly the problem is: <% System.out.println("....................................Step 1"); %> <jsp:useBean id="dropdown" scope="application" class="com.xxx.utils.DropDownCollections"/> <% System.out.println("....................................Step 2"); %> <bean:define id="countries" name="dropdown" property="countries" toScope="request"/> <% System.out.println("....................................Step 3"); %> The output on the console is: 15:02:53,937 INFO [STDOUT] ....................................Step 1 15:02:53,957 INFO [STDOUT] ....................................Step 2 15:02:54,147 ERROR [Engine] ApplicationDispatcher[/mobilemail_1_0] Servlet.servi ce() for servlet jsp threw exception org.apache.jasper.JasperException: Exception thrown by getter for property count ries of bean dropdown Step 1 and Step2 statements are printed on the console but Step 3 is not printed. So, there's something wrong in <bean:define..../> Sriram -----Original Message----- From: Swaroop George [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 2:49 PM To: Struts Users Mailing List Subject: RE: drop-down list help Think I got it.. Change ur method as public Collection getCountries() and try.. Swaroop -----Original Message----- From: sriram [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 2:17 PM To: 'Struts Users Mailing List' Subject: RE: drop-down list help Swaroop, I have given a system.out.println statement in catch block (as follows): public ArrayList getCountries() { ArrayList countries = new ArrayList(); try{ countries.add(new LabelValueBean("Australia", "1000")); countries.add(new LabelValueBean("New Zealand", "1001")); countries.add(new LabelValueBean("India", "1003")); } catch (Exception ex) { System.out.println(".............exception"); ex.printStackTrace(); } return countries; } But nothing is printed on app. server console except for the exception that I've mentioned before. Sriram -----Original Message----- From: Swaroop George [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 2:13 PM To: Struts Users Mailing List Subject: RE: drop-down list help Sriram, } catch (Exception ex) { ex.printStackTrace(); } This exception block wont be shown on the JSP page.. but will be shown on ur appserver's output window. Check whether any such exception is being thrown.. Swaroop -----Original Message----- From: sriram [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 2:00 PM To: 'Struts Users Mailing List' Subject: RE: drop-down list help Nagendra, I have modified the bean as follows: public class DropDownCollections { private ArrayList countries = new ArrayList(); public ArrayList getCountries() { ArrayList list = new ArrayList(); try{ countries.add(new LabelValueBean("Australia", "1000")); countries.add(new LabelValueBean("New Zealand", "1001")); countries.add(new LabelValueBean("India", "1003")); } catch (Exception ex) { ex.printStackTrace(); } return countries; } public void setCountries(ArrayList countries) { this.countries = (ArrayList)countries; } } Still I'm getting the same error. The stack trace is given below: javax.servlet.jsp.JspException: Exception thrown by getter for property countries of bean dropdown at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:964) at org.apache.struts.taglib.bean.DefineTag.doEndTag(DefineTag.java:266) at org.apache.jsp.userview_jsp._jspService(userview_jsp.java:199) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:210) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatc her.java:684) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDisp atcher.java:432) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispat ! cher.java:356) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav a:1069) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestPr ocessor.java:455) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 279) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invok! e(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.ja va:246) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241 5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatc! herValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke! (ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:59 4) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC onnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56 5) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:619) at java.lang.Thread.run(Thread.java:536) In stack trace, it's showing an error at line 199 of userview_jsp.java. This line has the following code: if (_jspx_th_bean_define_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) Further down the stack trace (not pasted above), it's showing error at line 2073 of the same file and the code in that line is: } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); --> line 2073 .... } Can you get any idea about why it's giving that error from the above information? Pl. inform. Sriram -----Original Message----- From: Nagendra Kumar O V S [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 1:27 PM To: [EMAIL PROTECTED] Subject: RE: drop-down list help hi, i guess u r not following the java-bean rules private ArrayList countries = new ArrayList(); public ArrayList getCountries() { // here u can populate the arraylist... as u did earlier return countries; } public void setCountries(ArrayList countries) { this.countries = countries; } this is what the java bean signature should look like.... -- nagi -------Original Message------- From: Struts Users Mailing <mailto:[EMAIL PROTECTED]> List Date: Wednesday, July 23, 2003 12:54:20 PM To: 'Struts Users Mailing <mailto:[EMAIL PROTECTED]> List' Subject: RE: drop-down list help Swaroop, I am trying to implement the way you have mentioned for populating drop downs. I'm getting the following exception: javax.servlet.ServletException: Exception thrown by getter for property countries of bean dropdown Here's the code that I'm using: <jsp:useBean id="dropdown" scope="application" class="com.xxx.DropDownCollections"> </jsp:useBean> <bean:define id="countries" name="dropdown" property="countries" toScope="request" /> Bean Class: package com.xxx; public class DropDownCollections { private ArrayList countries = new ArrayList(); public Collection getCountries() { //ArrayList list = new ArrayList(); try{ countries.add(new LabelValueBean("Australia", "1000")); countries.add(new LabelValueBean("New Zealand", "1001")); countries.add(new LabelValueBean("India", "1003")); } catch (Exception ex) { ex.printStackTrace(); } return countries; } public void setCountries(Collection options) { // No op, here to satisfy bean-ness. } } Any possible solution? Please inform. Sriram -----Original Message----- From: Swaroop George [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] Sent: Tuesday, July 22, 2003 6:36 PM To: Struts Users Mailing List Subject: RE: drop-down list help <jsp:useBean id="dropdown" scope="application" class="com.xxx.DropdownCollections"> </jsp:useBean> <bean:define id="months" name="dropdown" property="months" toScope="request"/> <html:select property="month> <html:options collection="months" property="key" labelProperty="value"/> </html:select> Hi this is a part of the page I developed.. (Ofcourse a commercial application..) I have a class called DropDownCollections.java Now in the class I have a method getMonths() which will return me a collection of months.. I am using the months collection to populate the options.. You can actually use an html:select instead of a nested:select The getMonths() returns a set of beans having two attributes key and value.. Key will be the month numbers 1,2,3,4.. While value will be month names Jan, Feb,.. While the dropdown is rendered the month name will be shown.. When the page is submitted the month num(key) will be set to the property 'month' Hope it helps.. Swaroop -----Original Message----- From: Rick Col [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] Sent: Tuesday, July 22, 2003 6:24 PM To: Struts Users Mailing List Subject: drop-down list help Hi, guys: I am a struts newbie. I have spent sevaral days trying build a struts page with several drop-down lists in vain. I am wondering there are any struts drop down lists examples out there. I appreciate your help. regards, __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com <http://sbc.yahoo.com> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ____________________________________________________ <http://www.incredimail.com/redir.asp?ad_id=309&lang=9> IncrediMail - Email has finally evolved - <http://www.incredimail.com/redir.asp?ad_id=309&lang=9> Click Here --------------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]