Servlets and database access - design considerations
Joined: Sep 24, 2004
I have a simple app that uses jsp taglib to display data from a database.
My App works fine but I have linited experience and was wanting to know some other people opion on my design approach.
The app basically from the tag lib call a bean that contains a method that connects and queries the databnase closes the record set etc..and returns an ArrayList of Strings, which is displayed in a jsp via the tag lib.
Now my question here is is just using a bean to access the DB ok and returning the data in an ArrayList Ok, or this there a better approach to doing this?
Joined: Oct 12, 2000
What you're doing is a good step on the correct path. You should however not do database access (even in this manner) from a JSP. Rather do it from a servlet (through your bean) and set the List in the request or session, then forward to the JSP and use that to display the data.