Win a copy of Learn Spring Security (video course) this week in the Spring 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic