• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets 4a question

 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got this nitpick:

Any way to get this logic stuff out of the jsp?

And my response was good question! What I am trying to do is place data in a table. The data is stored in an ArrayList, and each object in the ArrayList has 5 fields that need to be placed in their own cell in the object's own row of the table. Since the ArrayList is being retreived from the servlet code as an attribute, I can't figure out how to take the logic that iterates through each item in the ArrayList and prints the data stored in each field in the appropriate cell of the table out of the jsp. It seems to me that the scriptlet I'm using to iterate through the ArrayList has to be in the jsp, because the ArrayList itself is being passed as as attribute. The iteration logic is needed in order for the expression that follows to be able to print each item out to the table.
If I move this logic to the servlet, how can I provide the individual pieces of data to the table in the jsp?
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Carol Murphy:
... the ArrayList itself is being passed as as attribute. ...
If I move this logic to the servlet, how can I provide the individual pieces of data to the table in the jsp?


What if you put the individual pieces into the ArrayList before you pass the list as an attribues?
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So instead of setting the ArrayList of video objects as the attribute, do all of the iterating first, put that in an ArrayList and set that to an attribute? Hmmmmmm. Or would ArrayList be the right thing to use? Must research collections some more....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic