This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes best way to access the vector in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "best way to access the vector in jsp" Watch "best way to access the vector in jsp" New topic
Author

best way to access the vector in jsp

Gina Ferrara
Greenhorn

Joined: Jul 02, 2003
Posts: 6
Hello all,
I like to know the best way to access a already populated vector in jsp.
I have servlet that talks to the backend beans and populate a vector



now in the jsp I have the following code

So is this a best practice to access the object I have placed into the vector?
Is there a better way to do this?

Gena
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Yes. You can use JSTL/EL. JSTL has a c:forEach tag for looping through a vector. EL lets you ${xmlObject.name} output properties of the loop element.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Just to make sure that there is no ambiguity, Jeanne's "yes" answer was to the question:
Is there a better way to do this?


Java code in scriptlets is an extremely poor practice that it almost 10 years out-of-date.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: best way to access the vector in jsp
 
Similar Threads
AXIS2 - set conditions - XmlValueDisconnectedException
Query related to com.bea.xml.XmlObject
How do i collect XML object on a JSP page
Loading xml in JavaScript Fails
Loading xml in Javascript fails