Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets and database access - design considerations

 
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?

Ras
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
This will take every ounce of my mental strength! All for a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!