aspose file tools*
The moose likes Java in General and the fly likes arrayList display all in one row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "arrayList display all in one row" Watch "arrayList display all in one row" New topic
Author

arrayList display all in one row

dan steve
Greenhorn

Joined: Feb 12, 2011
Posts: 7
please can anyone help to show me what I can use to arrange data fetched from the database into an arrayList
I have this application having; DAO, SERVLET, JSP, RELAY AND DATABASE.
the problem no is that, when I fetched data from the database, using an arrayList, I used a syntax like this to display it in an html table

this is in my servlet....it displays all record in a single row.....can anyone help me out on this? I have only untill tomorrow before my head is chopped off.....please help..thanks in advance.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
It appears you have things more or less right; are you sure the inner element has what you want on one row, and not more?

rc
nithin chinni
Ranch Hand

Joined: Dec 02, 2010
Posts: 41
dan steve wrote:please can anyone help to show me what I can use to arrange data fetched from the database into an arrayList
I have this application having; DAO, SERVLET, JSP, RELAY AND DATABASE.
the problem no is that, when I fetched data from the database, using an arrayList, I used a syntax like this to display it in an html table

this is in my servlet....it displays all record in a single row.....can anyone help me out on this? I have only untill tomorrow before my head is chopped off.....please help..thanks in advance.


well you made a small mistake here. Here tr means a new row....... not td. so obviously inside the loop you have to write <tr> along with <td>...... hope that helps.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
The OP has two loops: the outer one goes through each element in a collection named 'mr' and generates a row for each one.

Each element is an array list; for each element of each array list, it generates one element in that row.

So if the array list is one record, it will indeed display each element of that record on one row. Unfortunately, I don't know what the OP wanted to do, since it isn't that.

rc
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

I don't think you have provided us with enough information to be able to help you. However I would like to point out that you should not be coding HTML in servlets or even using java code in JSPs.
You can do the same thing using the standard taglibs and EL like:
Not only is it much more readable, but it makes it much easier to add CSS classes etc.

Sean


I love this place!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: arrayList display all in one row