File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes a little question about outputting data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "a little question about outputting data " Watch "a little question about outputting data " New topic

a little question about outputting data

Sim Raina
Ranch Hand

Joined: Nov 20, 2003
Posts: 33
i have a servlet that connects to sql database and gets the info and then i print it to the browser the only problem is that when it prints it takes a long time to print like 3 to 4 minutes may be because there are too many records or may be i am outputting the data in a table. So i want the table to display the every field one by one instead of displaying it all together. thank you guys in advance.
i heard of this method called flush but i don know what that is

if u can't impress people with ur intelligence , confuse them with ur bullshit
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
you mean to say that it is taking 3-4 mins to render the page or does the server side process takes 3-4 mins???
Regarding flush, I think you want something like HTTP streaming. Well, simply flushing the stream while keeping the connection open, I think is browser dependent. It did not work in my browser(IE 5) when I tried it and you should not use this concept. If there are too many records, then one way is to display the records in batches of say 15 records per page and then let the user request for the next set of records.
Sim Raina
Ranch Hand

Joined: Nov 20, 2003
Posts: 33
what i want it to do is display the each row one by one like we see in sql. cuz that is how my work wants and it also occured to me to use the batches but they don't want it that way. so any other suggestions???

this si what i m doing
String ipaddress = GetRSVal( rs, "ipaddress" );
String username = GetRSVal( rs, "usrnme",Blank ) ;
String domain = GetRSVal( rs, "domain" );
String date = GetRSVal( rs, "t_date" );
String time =GetRSVal( rs, "t_time" );
String req = GetRSVal( rs, "REQUESTTYPE" );
prn.print( "<TR>" );
prn.print("<TD><p align=\"center\">" + ipaddress + "</TD>" );
prn.print("<TD><p align=\"center\">" + username + "</TD>" );
prn.print("<TD><p align=\"center\">" + domain + "</TD>" );
prn.print("<TD><p align=\"center\">" + date + "</TD>" );
prn.print("<TD><p align=\"center\">" + time + "</TD>" );
prn.print("<TD><p align=\"center\">" + req + "</TD>" );
prn.print("<TD><p align=\"center\"><A HREF=\"/WebLogs/Details?domain=" + domain + "&url=" + GetRSVal( rs, "int_url","" ) + "&usrnme=" + username +"&date=" + date+ "&time=" + time + "\"> Description </TD>" );
prn.print("<TD><p align=\"center\"><A HREF=\"" + domain + GetRSVal( rs, "f_file" ) + GetRSVal( rs, "p_parameters" )+ "\"> LINK </TD>" );
prn.println( "</TR>" );
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
For an easier way to generate html tables check out the FormattedDataSet. Out of the box it can generate an html table in 2 lines of code including the constructor. - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
I have just added a live demo page that allows you to type in a query and have the results returned as an HTML table with Sortable/clickable column headers. You can just hit submit when the default query comes up or you can enter your own query.
The demo is at
steve - - the easiest way to generate dynamic xml and html.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
I think one of your main problems is that browsers usually wait until the end of a table before displaying it, so even if you were to flush each row before moving to the next one, you still wouldn't see the table until it was complete.
To solve this you could try sending each row of the table as a whole table. To ensure that the columns match, you will need to set explicit widths for the columns, though. Try something like:

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: a little question about outputting data
It's not a secret anymore!