You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Meryl Silverburgh <si...@gmail.com> on 2006/04/02 19:51:56 UTC

What is the best way to send back a file as http response?

Hi all,

Can you please tell me what is the best way to send back a file as
http response in a Servlet?
Should I use NIO?
Or I just use the normal, open the file, read it a chuck at a time and
write that to the servlet output stream?

Thank you.

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


Re: What is the best way to send back a file as http response?

Posted by Leon Rosenberg <ro...@googlemail.com>.
Are we talking about big files? Otherwise just read it at once and
write it through a bufferedoutputstream.

leon

On 4/2/06, Meryl Silverburgh <si...@gmail.com> wrote:
> Hi all,
>
> Can you please tell me what is the best way to send back a file as
> http response in a Servlet?
> Should I use NIO?
> Or I just use the normal, open the file, read it a chuck at a time and
> write that to the servlet output stream?
>
> Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: What is the best way to send back a file as http response?

Posted by Mike Sabroff <mi...@cygnusb2b.com>.
You can

Kanishka Liyanage wrote:
> Why cannot you forward your response to the file URL
> if the file is available within the web application
> directory. 
>
> response.sendRedirect("File Location");
>
> Otherwise you can use the servlet output stream
>
> Good Luck
> -Kanishka
>
>
> --- Meryl Silverburgh <si...@gmail.com>
> wrote:
>
>   
>> Hi all,
>>
>> Can you please tell me what is the best way to send
>> back a file as
>> http response in a Servlet?
>> Should I use NIO?
>> Or I just use the normal, open the file, read it a
>> chuck at a time and
>> write that to the servlet output stream?
>>
>> Thank you.
>>
>>
>>     
> ---------------------------------------------------------------------
>   
>> To unsubscribe, e-mail:
>> users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail:
>> users-help@tomcat.apache.org
>>
>>
>>     
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   

-- 
Mike Sabroff
Web Services Developer
mike.sabroff@cygnusb2b.com
920-568-8379


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


Re: What is the best way to send back a file as http response?

Posted by Kanishka Liyanage <ka...@yahoo.com>.
Why cannot you forward your response to the file URL
if the file is available within the web application
directory. 

response.sendRedirect("File Location");

Otherwise you can use the servlet output stream

Good Luck
-Kanishka


--- Meryl Silverburgh <si...@gmail.com>
wrote:

> Hi all,
> 
> Can you please tell me what is the best way to send
> back a file as
> http response in a Servlet?
> Should I use NIO?
> Or I just use the normal, open the file, read it a
> chuck at a time and
> write that to the servlet output stream?
> 
> Thank you.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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