tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Wilson" <jnwil...@dallas.photronics.com>
Subject Re: Response and file downloads
Date Mon, 01 Nov 2004 22:19:34 GMT
Just an FYI: I was unable to get the body onLoad() to work properly on 
both IE5 and Mozilla  - forget exactly why but it was supposed to work! 
Anyway, I instead used an IFRAME (internal frame) which I added to my 
forms' output stream(the same form the user just clicked submit() on - 
essentially a reload with new status information updated and a 
tad-bit-o-extra-output). The little-bit-o-code is below:

<iframe name="thisIFRAME" id="thisIFRAME" src="get_doc?key_id=1668" frameBorder="0" width="0"
scrolling="no" height="0"></iframe>

This creates a hidden(I don't want to argue the metaphysical side of this) window which in
effect 'clicks' on the link I created. Works nicely...so far.
I'm not a HTML/Javascript guru so I can't tell you how long this trick will work.

Good luck

--Jonathan


Justin Ruthenbeck wrote:

> At 12:17 PM 11/1/2004, you wrote:
>
>> I am not sure what you are refering to as atypical or robustness...
>
>
> I meant to say that you could approximate the behavior you were asking 
> for (dual response), but doing so would be hackish.
>
>> How do other sites generate files on the fly (take it out of a 
>> database, or a report just run), on form submit, and send them down 
>> the line and not run into this problem?
>
>
> Like fzlists said, you'll see most sites load a page in response to a 
> download request which either provides a link which the user can click 
> on to download the binary content (right click, "save as" in IE), or 
> that scripts the browser to automatically begin downloading.  This is 
> how CNet, Yahoo, and others do this.
>
>> I see many people posting many places on the net that they are using 
>> the response to send a file, a lot of them are getting this 
>> IllegalState, but I never really found a followup solution that 
>> really fit my needs.
>>
>> Why would the possibility exist to push a file through the response 
>> if it leaves you with the ability to go nowhere after?
>
>
> If your browser submits a request and the response is a mp3 (through 
> either URL inspection or Content-Disposition header), the browser will 
> prompt the user to Save/Open/Run/whatever the file (and won't try to 
> display it).  Once the file has been saved, it will leave you at the 
> original page from which the file was requested.
>
> Point being that after you push binary content through the response, 
> it leaves you with whatever the previous page's options were ... 
> there's really no contradiction in doing so.
>
> justin
>
>
>
> -----Original Message-----
>
>> From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
>> Sent: Monday, November 01, 2004 2:56 PM
>> To: Tomcat Users List
>> Subject: Re: Response and file downloads
>>
>>
>>
>> Luc,
>>
>> At 11:42 AM 11/1/2004, you wrote:
>> >I am having a wee problem with using the response.
>> >
>> >I have a form on a page, with a submit button to download a file. That
>> >file is being pulled from a database and pushed to the response.
>> >The problem I am having, I just used that response to submit the page,
>> >so I am getting and IllegalStateException, even though it is still
>> >pushing the file to the browswer
>> >I also want to be able to send a redirect after the file is downloaded
>> >(so I can refresh the page so the form submit page is regenerated, 
>> since
>> >we are using a string to determine unique submits are only coming from
>> >the pages we generated, and not the browser address bar)
>> >
>> >Can we get a new response from the session variable (the one available
>> >to jsp writing) to send the file, then get another new response to
>> >perform a redirect....
>> >Basically I want to be able to do something like
>> >
>> >the form submits, and passes to the applications perform methods 
>> through
>> >the jsp catching the submit
>> >response = new Response
>> >response.sendFile
>> >response = new Response
>> >response.sendRedirect
>> >(yes I know those are not actual methods and classes, just trying to
>> >explain what I want)
>>
>> Your understanding of how, exactly, the http protocol works is
>> incorrect.  Because it is a (single) request, (single) response 
>> protocol,
>> what you're asking for cannot be done.
>>
>> It seems like what you want is for a user to fill out a form, click
>> submit, then be presented with a new, fresh, form again ... with the 
>> file
>> download on the side.  If you have determined that you absolutely want
>> this behavior (it's atypical, so doing it won't be particularly robust),
>> consider programmatically opening another browser window on form submit
>> from which the download will happen ... and reload your form in your
>> "main" browser window.  This will, of course, subject you to any
>> headaches associated with javascipt window opening.
>>
>> justin
>>
>>
>>
>> ______________________________________________
>> Justin Ruthenbeck
>> Lead Software Engineer, NextEngine Inc.
>> justinr - AT - nextengine DOT com
>> Confidential. See:
>> http://www.nextengine.com/confidentiality.php
>> ______________________________________________
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message