• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

JSPs or Servlets or JavaBeans for DB queries?

Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

author and iconoclast
Posts: 24207
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    Bookmark Topic Watch Topic
  • New Topic