I have a small form, which when filled would hit a DB, fetch some data and this data needs to be populated onto a JSP page.
My questions are:
1. Since we are talking about a datagrid being displayed, can we fetch a resultset and set it to session/ request scope - I think this is a bad design choice. But how else would I display the data?
2. If I do not use the above approach, how else can I do it? Can I store the data in a collection that can be set to request scope and display from there?
There would be too much application processing logic on the JSP if you were to pass the ResultSet object. I would suggest you populate a Bean which has all the necessary fields and pass that to the JSP. Once inside the JSP you could then iterate through the List and display the necessa\ry data (with proper formatting) as required.
1. Fetch the ResultSet.
2. Loop: contents of the ResultSet.
3. Populate the bean fields with values in the ResultSet.
4. Add the Bean to a List.
5. Continue Loop for the entire ResultSet.
6. Pass the List<Bean> in the request to the JSP.
7. Loop: In the JSP iterate through the above List.
8. Display the needed fields in the bean.
9. Continue the Loop for the entire List.