• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

displaying results vertically

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm building a page using jsp that pulls data from a database. The page should look a bit like this :

Name:ABC
Date: 12/12/2004
Description rogramming is fun!
Cost:$100.00


Name:XYZ
Date:1/8/2005
Description:Fruits are yummy!
Cost:$30.05

Name: QRS
Date:8/8/2005
Description:A great tv show!
Cost:$50.90

etc...etc...

Basically, the sql query loops through the db and displays the results like that with the same sub headings. I don't want to do it where the sub headings go horizontally across the page (won't have the same visual effect).

I was thinking part of the code may have something like this:


I'd like to keep things simple as can be. Beans and servlets confuse me.

Any suggestions please?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what exactly you are asking? Do you have a problem with this approach? It seems workable to me.
Only that it would be bad practice to put DB access code in JSP pages - that should really go in a Java class, but maybe that can be changed once you're a bit more familiar with the servlet/JSP API.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make the table headers once horizontally and then loop the values.

Its better to go for a clearer code and try best practices from starting. May be its just me.

Move your all presentation code to your JSP, request/response handling to your controller/servlet then use beans or transfer objects to transfer values. Your DB code should be in some of your normal plain java classes. In short practice MVC Model 2. Its easy, and make clear seperation. No more confusions.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'd like to keep things simple as can be. Beans and servlets confuse me.



If you are going to be working in web apps with JSP, these are concepts that you will not be able to avoid.

I would seek out tutorials and other literature on the subjects.
 
jan frank
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I spent some time at it and I DID get it in the format I wanted. Yeaaaah!
 
reply
    Bookmark Topic Watch Topic
  • New Topic