Forum Moderators: open

Message Too Old, No Replies

ASP Question

When does it spit out HTML?

         

tesla

7:00 pm on Nov 8, 2002 (gmt 0)

10+ Year Member



What causes ASP to pause to spit out HTML to the browser?
For example. Lets say I have code like this:

HTML
HTML
HTML
<%ASP CODE%>
HTML
HTML
<%ASP CODE%>
HTML

I have noticed that no HTML will be spit to the screen until the last line of ASP code is completed. Other times with large ASP files, it will spit the first bunch of HTML code out before starting the next ASP code block. How does one determine how the ASP will operate with respect to when the HTML code will be sent to the users browser.

What I would like to do is add a quick text message at the start of the ASP file such as "Processing..." To stop other accessing scripts from timing out if the ASP does not execute quickly. But Despite the fact that I have added an HTML header and an HTML message at the start of the ASP code, it will not print it until the ASP code completely finishes.

Any Ideas?

Thanks,

moonbiter

7:16 pm on Nov 8, 2002 (gmt 0)

10+ Year Member



AFAIK, an ASP file is completely processed on the server before it is sent to the client browser. According to Microsoft [msdn.microsoft.com]:

"A server-side script begins to run when a browser requests an .asp file from your Web server. Your Web server then calls ASP, which processes the requested file from top to bottom, executes any script commands, and sends a Web page to the browser."

The only reason I can think of that a large ASP file would seem to pause on the browser is that it is returning out a lot of complicated HTML or client-side JavaScript.

tesla

10:10 pm on Nov 8, 2002 (gmt 0)

10+ Year Member



I'm not sure why it "pauses" either. But I have a huge script that generates two tables. Each table takes 2 minutes to render. When it completes the first, it is displayed, 2 minutes later it adds the second table.

I wonder if I can get around this with a "Response.Write".

I shall experiment.............

Result: Same dang thing. THe response.write did not render result early.

Hmmm... I'm stumped

[edited by: tesla at 11:06 pm (utc) on Nov. 8, 2002]

moonbiter

10:53 pm on Nov 8, 2002 (gmt 0)

10+ Year Member



Ah ha.

I believe this is just a consequence of the browser trying to render really big tables.

IIRC, some browsers (MSIE, for example) won't render a table until all of the table information has been read. If you have two huge tables, it could be reading the first table, and when it has all of the info displaying it, while the second table is still loading.

txbakers

2:35 am on Nov 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, check your database, if it's Access you will have a great deal of trouble to render pages.

It's unGoodly slow.

DaveN

2:47 am on Nov 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



your problems is how long it takes to actually collect all the data for the table.

the html page starts off

<html>
<body>
<table>

asp bit

</table>
</body>
</html>

it cant render the table until it has built the table content and published </table>.

try to move away from the table and use a css this way you can design the asp to backfill areas at a time.

DaveN

tesla

9:10 pm on Nov 9, 2002 (gmt 0)

10+ Year Member



Ok, I have found something that works but I really don't understand why.

If I place

<Table border=0><TR><TD>Processing . . . .</TD></TR>
</Table>
<Table border=0><TR><TD>Order Date: <%=Date%></TD></TR>
<TR><TD>Order Date: <%=Time()%> EST</TD></TR></Table>

At the start of my ASP file, it will spit it out before it continues on with the rest of the file. I Tried various combinations and it seems it wants to have two tables and some ASP code. If you remove one table, it does not work. If you remove the ASP it does not work. Its a mystery. I'm sure there are other combinations of HTML and ASP that will work, but it seems to be three required elements <HTML><HTML><ASP> And each should result in something to the screen.

I take it all back:
This was on my local site and all that was in the ASP file was the code aboved followed by a big FOR delay.
When I put the exactly code at the start of my larger ASP file on my real server, the behavior changes. On the real server I have not yet succeeded in every getting it to pause. with code like above.
I have tried adding more HTML and more intermixed ASP and nothing seems to work. I'm thinking it most have something to do with buffer sizes. My local machine has a weak buffer size and the real server has much larger. Since I know that a really large table of the real server will result in the desired behavior it tends to back up my buffer theory.

Any ideas?

threecrans

7:44 pm on Nov 11, 2002 (gmt 0)

10+ Year Member



Check out Response.Buffer and Response.Flush

Response.Buffer --> Defaults to true in ASP 3, tells server to buffer output until all scripts have been executed.

Response.Flush --> Sends all buffered data to the browser.

Also, if the browser seems to "hang" for excessive periods of time, it may be due to the browser having trouble rendering complicated tables or scripts and not due to any server-side execution. To check this, telnet into your web server and request a page. If you quickly get a response, you know it is a rendering issue with the browser. I have run into this with Netscape several times.

Enigma

4:12 am on Nov 28, 2002 (gmt 0)

10+ Year Member



How large is the page?

If you add headers and footers to the table then they are supposed to render before the table body. I say supposed to as this is not yet supported by the majority of browsers.

Xoc

12:15 pm on Dec 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Browsers have a much easier time rendering tables if you specify the column widths. If you don't specify, then the entire table has to be read in before it can figure out how wide to make them.

The response.buffer and response.flush are what you want, also.

aspdaddy

12:24 pm on Dec 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



flush used after each closing </table> tag is a good one for big data sets.

Also, this is much faster way of writing to the buffer in asp.

With Response
.write "<TR><TD>Order Date: "
.write Time()
.write "EST</TD></TR></Table>"
End with