• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with <logic:iterate>

 
gunjan shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Romit Bose
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic