Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect does not allow display of html? 4

Status
Not open for further replies.

ahmun

IS-IT--Management
Jan 7, 2002
432
0
0
US
I have a page that dynamically creates a PDF based on data from a database. Once the code loops through the various tables and assembles the data, I use a response.redirect to take the user directly to the pdf file.

I would like to put up a simple "please wait while the pdf is generated" message on the screen, but for some reason, if I have a response.redirect on the screen, no html will show.

I've tried to set the buffer to true, and then response.flush it after the closing </html> tag, then running the response.redirect after the flush, but nothing happens... and the &quot;please wait...&quot; message is displayed, but I have stopped all processes.

so it goes a little something like this:

Scenario 1: Body info doesn't show up
Code:
<html>
<header stuff...>
<body>
<p>Please wait while the pdf is generated...</p>
</html>
<%
  'the serious code goes here...
  'the code finishes and writes a pdf file...
  response.redirect &quot;/docs/somePDF.pdf&quot;
%>
Scenario 2: Use of response.buffer
Code:
<% response.buffer = true %>
<html>
<header stuff...>
<body>
<p>Please wait while the pdf is generated...</p>
</html>
<%
  response.flush

*********************
'I do the flush here to try to get the browser to see the HTML text before I run the code... in hopes that I can allow the user to see that message, then generate the pdf, then response.redirect the user to the dynamically generated file
*********************
Code:
  'the serious code goes here...
  'the code finishes and writes a pdf file...
  response.redirect &quot;/docs/somePDF.pdf&quot;
%>


Earnie Eng
 
That's (almost) what I do at work. Only modifier to Tarwn's thing would be to actually redirect to the page that makes the PDF, else you may end up requesting the PDF that doesn't exist yet.

My first page is something like:
<html><head><meta http-equiv=&quot;Refresh&quot; content=&quot;2; url=<%=str_PathInfo%>&quot; /></head>
<body STYLE=&quot;font: bold 12pt arial;&quot;>
PDF creation in progress, please remain patient.
</body></html>

(obviously I generate str_PathInfo above - it redirects to the ASP page that builds the PDF, which in turn redirects to the finished PDF, like so)

<snippet of second page (well, third really - an include off the second that does all the work)>
<body STYLE=&quot;font: bold 12pt arial;&quot; onLoad=&quot;javascript:document.location='PDF created in <%=round((now-lng_Time)*60*60*24)%> seconds.<br />
You should be redirected to the PDF now. If you have not been redirected within a few seconds, you can click <a href=&quot; link</a> to access the PDF.
</body></html>
</snippet>

codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
As an aside when generating PDFs - remember to password protect them.

We produce PDF reports for clients' employees, and it just wouldn't do for them to go modifying their scores :p



codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
i'm new, also, to the dynamic PDF generation idea... and was wondering if password protecting allows for viewing w/o password...

in other words: user can download and view, but cannot edit (or append/delete/whatever) even if they have adobe Acrobat...

Earnie Eng
 
Well, we use activePDF for PDF generation (we have some issues with it, but hey it works, generally).

It allows you to set one password for viewing, and another for editing/printing/savings/etc


codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
onpt, veep, codestorm, tarwin... thanks to alla ya for your help!

Earnie Eng
 
oh... and thanks, medic, for jumping in, too!

Earnie Eng
 
now here's a fun twist to my question...

Is it possible for that Meta refresh tag to redirect the page to another frame or window?

sounds like a stoopid question since it is a &quot;refresh&quot; but I give the question a shot anyways.

Earnie Eng
 
yep its possible ;)

<meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://www.mypage.com&quot;>




www.vzio.com
ASP WEB DEVELOPMENT



 
ahhh code tags this time :(

Code:
<meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://www.mypage.com&quot;>

I sure wish you could edit posts on tek-tips some times.

www.vzio.com
ASP WEB DEVELOPMENT



 
Ok... let me clarify...

I have a page sitting in an IFRAME. within this IFRAME, I have a form.... it does something, then I click submit...

I am trying to make the META refresh tag redirect to the parent frame.

Earnie Eng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top