• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSPs or Servlets or JavaBeans for DB queries?  RSS feed

 
Paul Hoffman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

What is the "standard convention" for querying a database and then displaying the data? Currently, I have a JSP page which contains a simple form that submits the search criteria to a servlet. The servlet then (which has a doPost() method and a query_db() method) simply connects to the database and pulls the related records. I can get it to work - that's not the problem.

My question is - what is the "protocol"? The way I am doing it has some downfalls - when I want to display my results, I'm forced to do so through a series of out.println statements. I realize that using JSP is a better method because it is much easier to code the presentation, but I'm just not sure how to do it.

Any feedback on how everyone else does it?

Thanks!!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One JSP for the form; a servlet to process the form and create a data bean; a second JSP to display the data bean. The servlet should store the data in the session context and redirect to the second JSP.

The latest issue of the JavaRanch Journal includes a wonderful article on the state of the art in JSP/Servlet architectures here. Read it twice -- there's an enormous amount of wisdom distilled into a small space.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!