Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

output in servlet

 
srini kami
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am having trouble formatting output from database to browser.
I have follwoing code in try block of servlet.
try{

Statement stmt = conn.createStatement();
String req_show= "select title from request";

ResultSet rs = stmt.executeQuery(req_show);

while (rs.next() ) {

String titl = rs.getString(1)+"\n";
out.println(titl);out.println("\n");
I get values from above column (title)but they are showing in one row like following
//output
test test check
I want it to show as a cloumn
test
test
check
how do i do that?. I will appreciate it it if you could help me with this.
Thank you
 
Sam Walker
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If out is of type PrintWriter and you�re trying to display your data in a browser then try this
out.println(titl+�<br>�);
 
srini kami
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam
Thank you. I tried it and it works fine now.
Thank you
 
Sam Walker
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You�re welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic