File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes problem with <logic:iterate> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem with <logic:iterate>" Watch "problem with <logic:iterate>" New topic
Author

problem with <logic:iterate>

gunjan shah
Greenhorn

Joined: Apr 21, 2009
Posts: 3
Hey guys I am trying to fetch the information present in servlet into jsp page and i am getting difficulty in writing above tag.
So please help me.
For your help i am writing my code here , so that you can understand it.


now see this lines in Action classes.



now tell me how to write that tag, i m writing here for trial but i m sure it is wrong, so please help me




So please help to solve it.


"Learn and Grow rich"
"Painting comes to the painter , poem comes to the poet similarly code comes to the developer"
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Hi gunjan,

I don't really understand what are you trying to do but I have seen some thins that seem to be wrong, I thing your code will not compile at all!

You are using Public and it should be public, not capital letters! The same for the For loop and the While. You have also called an ArrayList final, that is not allowed!!! final is a reserved word, as you cannot call a variable 'class' or 'if' you cannot call it final, read this about java naming convention

And then, where does the rs came from? Are you storing the result in an static class attribute? Where does rset came from? I see rs and rset vars in your code but I don't know where they come from...

Then creating the tag is another step... You can read this "custom tags in JSP pages tutorial"
gunjan shah
Greenhorn

Joined: Apr 21, 2009
Posts: 3
Dear Friend Alberto ,
You are completely right about all the things you pointed out.
Frankly speaking I was becoming a little bit lazy by posting only the main sentences of the code and that too incorrect due to my hurry,but please forgive me for that
here with I am attaching the code.





now look at another class.



And now in my Action class, I have



Then please can you specify what should be my jsp code, to fetch p1,p2 and p3 in the jsp form.
Thanks for your help , and thanks for taking time for it.
I am sorry for all the inconvenience.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
gunjan wrote: Frankly speaking I was becoming a little bit lazy by posting only the main sentences of the code and that too incorrect due to my hurry,but please forgive me for that


hahaha funny answer, let's see if I can help you.

You want to use <logic:iterate>, I have no idea that that existed so I cannot help you with that too much, but I guess that this tag is expecting an array, or a List or something like this to iterate over and you are not setting anything like that, you are just setting String attributes to the request, I suppouse that you only recive one row per select because you are only sending the last row of the resultset to the application.

I think you should create a List with VO objects and then access them in the application iterating the List and showing the VO.product, VO.family, etc...

What's the target of this? Is it learning how to use <logic:iterate>? Is it just showing the information of the database in the screen or what?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
hi,
The <logic:iterate> goes like this :
You lets say you have a collection of objects, and they contain some property called someProperty. now you create a list of such objects and load it on request by the name somDTOList from your action...(using request.setAttribute()) and then use it in your JSP like :
 
GeeCON Prague 2014
 
subject: problem with <logic:iterate>