dcsimg
I want download multipile files from server ...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pradeep_patil
Posted On:   Wednesday, September 1, 2010 06:55 AM

by following code download single file only , I want to download multiple files, I use for loop but it,s not working.. how it is help.........me ......plz <% int i=0; while(i <=2) { out.print("i Elements :"+i+" "); String dwFilename ="C:\downloadJSP\raj.zip"; // set the http content type to "APPLICATION/OCTET-STREAM response.setContentType("APPLICATION/OCTET-STREAM"); // initialize the http content-disposition header to // indicate a file attachment with the default filename BufferedInputStream buf=null; ServletOutputStream myOut=null; try { myOut = response.getOutputS   More>>

by following code download single file only , I want to download multiple files, I use for loop but it,s not working.. how it is help.........me ......plz


<%
int i=0;
while(i <=2)
{
out.print("i Elements :"+i+"
");
String dwFilename ="C:\downloadJSP\raj.zip";
// set the http content type to "APPLICATION/OCTET-STREAM
response.setContentType("APPLICATION/OCTET-STREAM");

// initialize the http content-disposition header to
// indicate a file attachment with the default filename
BufferedInputStream buf=null;
ServletOutputStream myOut=null;
try {

myOut = response.getOutputStream( );
File myfile = new File(dwFilename);

//set response headers
response.setContentType("text/plain");

response.addHeader("Content-Disposition","attachment; filename="+dwFilename );

response.setContentLength( (int) myfile.length( ) );

FileInputStream input = new FileInputStream(myfile);
buf = new BufferedInputStream(input);
int readBytes = 0;

//read from the file; write to the ServletOutputStream
while((readBytes = buf.read( )) != -1)
myOut.write(readBytes);

} catch (IOException ioe){

throw new ServletException(ioe.getMessage( ));

} finally {

//close the input/output streams
if (myOut != null)
myOut.close( );
if (buf != null)
buf.close( );


}
i++;
}
%>

   <<Less

Re: I want download multipile files from server ...

Posted By:   shanpink16  
Posted On:   Friday, September 6, 2013 01:15 PM

Hi......:)
Welcome to this site, sorry I don't have sufficient knowledge about your query.
You have to consult with an expert in this field so you will solve this. 
About | Sitemap | Contact