• Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying results vertically

 
jan frank
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I spent some time at it and I DID get it in the format I wanted. Yeaaaah!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!