Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java servlet :: how to download multiple files

Reply
Thread Tools

java servlet :: how to download multiple files

 
 
anil001
Guest
Posts: n/a
 
      08-19-2003
my requirement is to download multiple files on click of submit button.
At present the following code sniplet downloads single files
----------------------------------------------------------------
response.setContentType("application/download");
response.setHeader("Content-disposition","attachment; filename=" + strAttachName);
response.getOutputStream().write(ByteArray());
----------------------------------------------------------------
does anybody know it?

thx
 
Reply With Quote
 
 
 
 
biro
Guest
Posts: n/a
 
      08-19-2003

> my requirement is to download multiple files on click of submit
> button.
> At present the following code sniplet downloads single files
> ----------------------------------------------------------------
> response.setContentType("application/download");
> response.setHeader("Content-disposition","attachment; filename=" +
> strAttachName);
> response.getOutputStream().write(ByteArray());
> ----------------------------------------------------------------
> does anybody know it?



If you mean you want the server to send the user several files after they
click submit once, then I don't think its possible.


 
Reply With Quote
 
 
 
 
Steve Claflin
Guest
Posts: n/a
 
      08-19-2003
biro wrote:
>
> > my requirement is to download multiple files on click of submit
> > button.
> > At present the following code sniplet downloads single files
> > ----------------------------------------------------------------
> > response.setContentType("application/download");
> > response.setHeader("Content-disposition","attachment; filename=" +
> > strAttachName);
> > response.getOutputStream().write(ByteArray());
> > ----------------------------------------------------------------
> > does anybody know it?

>
> If you mean you want the server to send the user several files after they
> click submit once, then I don't think its possible.


I'm also pretty sure that the way http works you can send only one
response; since a response corresponds to a file for a download, that
would mean you could send only one file.

For the content type you have listed, it seems that you would want to
put them all into a zip file and just send that. But, if it's supposed
to be dynamic content, you probably wouldn't want to have all possible
combinations of files stored in advance. If you want to build the zip
on the fly, see: http://www.mike-levin.com/java/zipoutputstream.html .

Otherwise, you could return an html page that lists all the individual
files as links, and let the user manually download each one (or come up
with a scheme that automates that process).


--
Steve
--
http://www.steveclaflin.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Servlet File Download - java.lang.IllegalStateException: Cannot forward after response has been committed PythonAnimal@gmail.com Java 9 09-04-2007 05:10 AM
Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response javadev Java 5 11-16-2006 11:22 AM
Download Servlet for .zip-Files on IE 6 and https StefanSt Java 3 08-24-2005 06:38 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments