• Post Reply Bookmark Topic Watch Topic
  • New Topic

print the result from the database

 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys, I have a detail question and don't know how to figure out. here is the code,

I can print out the result correctly, there are three rows of result from the database, but they are shown in one row on the browser, how could i show the result one row after another to let it looks pretty?
thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML uses "<br>" to add a line break, although you may wish to use an HTML table instead if there are several data points in each row. Also note that HTML treats consecutive spaces as if there was just a single space - a table might help with that as well.
 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you mean inside the while(rs.next(){}?, maybe don't need html here.
 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to do the code by a for phase

but I get the error, someone know why?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "the error"?

You need to create proper HTML - there's more to a table than "<tr>" tags. If you don't know HTML, I recommend to start practicing by creating HTML by hand to see how it looks in a browser. Once you have the effect you want, you can incorporate it into your servlet.
 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post complete code. which database you are tyring to access?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sai rama krishna wrote:can you post complete code. which database you are tyring to access?

This is an HTML problem, the DB has nothing to do with it.
 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree.
 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code get no error, but the result in one row。


there are three rows of result in the table, i just want to get the result in three rows.

I follow your advice and store the result in the java beans, then I wrote the jsp.


in the for loop, they get the same result, somebody tell me?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:You need to create proper HTML - there's more to a table than "<tr>" tags. If you don't know HTML, I recommend to start practicing by creating HTML by hand to see how it looks in a browser. Once you have the effect you want, you can incorporate it into your servlet.
 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe use continuer outer, to jump out the loop and print the result.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're suggesting, but it sounds more complicated than to create correct HTML.
 
Ma Yao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
proved to be your are right ulf, by using table in html and will do.


I focus on java code, focus on for loop, and can't get the right result.But I am bothering and think in bad way.
 
sai rama krishna
Ranch Hand
Posts: 524
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is good example
http://www.java-samples.com/showtutorial.php?tutorialid=619

It puts in different columns of a row. You can change your code accordingly if needed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!