Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dynamic String Array in Struts

706710Oct 27 2009 — edited Oct 29 2009
Hi,
We are facing an issue as shown below.(Sorry for posting struts query here)
-----------------------------------------------------------------------------------            
In jsp page ::
       <logic:iterate id="countryNameDet" name="form" property="countryNameDet">
             <tr>                
                  <td align="left" colspan="3">
                    <bean:write name="countryName" property="country_Name" />        
            </tr>
       </logic:iterate>
-------------------------------------------------------------------------------
Java code as shown below ::
            
            List countryNameDET = new ArrayList();
            countryNameDET = CountryDAO.getCountryDetails(); //access db and retrieve country Details as a list 
            form.setCountryNameDet(countryNameDET); //countryNameDET is the list set in the form     
            StringTokenizer st = null;
            CountryPOJO country = null;
            Iterator iterator = countryNameDET.iterator();         
            String[] countries = new String[3]; 
                       
            while (iterator.hasNext()) {
                  country = (CountryPOJO) iterator.next();
                  int counter=0;
                 SOP(country.getCountry_Name()); //we get period sepearated Countries (Example : London.Mumbai.Calcutta.Bangalore.Brisbane)
                  st = new StringTokenizer(country.getCountry_Name(), "."); //stringTokenizer to Tokenize Countries and retrieve individual countries                              
                  while (st.hasMoreTokens()) {
                        countries[counter] = new String(st.nextToken());
                        System.out.println("Country is -->"+countries[counter]) // display individual countries
                       counter= counter+1;
                  }                                  

            }
//how do i need to set the String Array here and access in jsp (in Struts)---> Please need help forum members..
//how do i neeed to write the logic iterate tag for Displaying individual countries one below the other in jsp ???
When I tokenize the Strings I get 3 independent strings.which I need to display in the jsp page using logic:iterate one below the other how do I do that
In jsp output should be

London
Mumbai
Calcutta
Bangalore

Could you please help me with the code in JSP and how to set the countries in Java.(Action class)...

I will be highly obliged if you could please help me out !!

Edited by: Deepak_A_L on Oct 27, 2009 10:30 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2009
Added on Oct 27 2009
6 comments
888 views