aspose file tools*
The moose likes Servlets and the fly likes Which is Best Way to Get a List for JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Which is Best Way to Get a List for JSP" Watch "Which is Best Way to Get a List for JSP" New topic
Author

Which is Best Way to Get a List for JSP

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
I need to get a list of users for a JSP select list. The list is hidden unless a user clicks a button.

My question is this. Which is the better metdod?

I can either get the list in my servlet response and set this string to a session attribute then use JSTL to populate the select list.

Or

Run jQuery when button is clicked and populate select list with return string.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

Unless the content of the list is dependent upon data that can't be known until after the page has been sent to the client, I'd render the list as part of the JSP before shipping it off to the client.

Why add all the extra moving parts if you don't have to?
[ July 15, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Thanks Bear
 
Consider Paul's rocket mass heater.
 
subject: Which is Best Way to Get a List for JSP