• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iterator in Struts 1

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a list in my session.
My jsp page:




Can I use Struts iterator to loop through the list (myList)?
I am using Struts 1.

Regards
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this way it works.
At first set the list in request attribute in Action class



And in JSP using Logic Iterator to collect them.

 
Manoj Paul
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kartik
Thanks for the reply

# <logic:iterate id="myList" name="myList" scope="request">
# <bean:write name="myList" />
# </logic:iterate>



Where should I make the changes if I want to display the value of each ("description") of my list in my jsp page using
out.println();

Regards
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you need again out.println ?
The code which I had given will automatically displays all the values of the list in the JSP.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why do you need again out.println ?


Agreed, if you want to display the description property of the elements in the list, then I think you should use the property attribute of the bean:write tag (but I'm not sure, I'm not good at Struts 1.x)...
 
Manoj Paul
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kartik,
The data is not displaying in my jsp page.

Here's my method in the Action class




This is my jsp page:



Can you figure it out?
I checked that request .getAttribute always point to null

Thanks & regards
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
session.setAttribute("TARIFF_CATEGORIES_LIST", tariffCategoriesList);
httpRequest.setAttribute("TARIFFCATEGORIESLIST", tariffCategoriesList);


This lines should suppose to be at end of try loop i.e at line number 105.
And after writing this lines write Sytem.out.println to check in action class itself whether its having value or not.
And one more thing like had you declared "request" in JSP? as am not able to see in the jsp.
 
Manoj Paul
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

And one more thing like had you declared "request" in JSP? as am not able to see in the jsp.


No
Request is an jsp implicit object.. Do I need to declare it still?
Please advice

 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya its my mistake, it will come automatically.
But are you able to see the results in action class or not?
 
Manoj Paul
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kartik!

To descibe you in more detail
Here's my jsp page coding


You could see that within the for-loop there is a
The data is diplaying fine here. But using this that is within the for-loop the value showing in the text field is that of the value of the

So thats where the problem is if I use any Html element in my code the value showing is that of some other elements.
Yes the data is displaying in the Action class (i.e both description and tariff_Category_Id) of the complete list.

Please advice if you can.

Regards
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic