wood burning stoves 2.0*
The moose likes JSP and the fly likes Downloading a multiple file from server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Downloading a multiple file from server" Watch "Downloading a multiple file from server" New topic
Author

Downloading a multiple file from server

anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
Hi,

Jsp get data from database displays message Id's to the user , user select N number of Message Id's as per Message Id's i Created xls files and kept in the one folder on server , i want to download the multiple files that has been created as per the user selection . Give me clarification to download mutiple file from server by using jsp or servlet

below is the code for downloading a file from server


response.setContentType( "application/vnd.ms-excel" );
response.setHeader("Content-Disposition","attachment; filename=\""+MSG_LVL_NO+"_"+cifId+".xls\"");
response.setHeader("cache-control", "no-cache");
response.setHeader("Pragma","no-cache");
java.net.URL url=new java.net.URL("file://./"+"Download-back/"+MSG_LVL_NO+"_"+cifId+".xls");
File file=new File(url.getPath());
System.out.println("Path:"+file.getPath());
System.out.print("file exist:"+file.exists());
java.io.FileInputStream fileInputStream =new java.io.FileInputStream(file);
BufferedInputStream bin=new BufferedInputStream(fileInputStream);

int i;
byte[] b=new byte[10];
ServletOutputStream sosStream= response.getOutputStream();
while ((i=bin.read())!=-1)
{
sosStream.write(i);;
}

sosStream.flush();
sosStream.close();
bin.close();
fileInputStream.close();



this able to download single file from N number of user selection

how get download N number files as per user selection
[ July 13, 2005: Message edited by: anilellendula kumar ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have you considered zipping the files into one archive?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
No,



i am not considering zipping the files on archie.
anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
clarification my problem!


n jsp page having all message id's it has come from database, user will select message id's he will submit, the all messageid's go to the another jsp page this will create xls files as many messageid's user selected , these xls sheets contains all database data, in same jsp i have written above code to download the created excel sheet files, here instead of downloading all files it is get downloading only one file.., reaming files are not ...
anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
hi,
Pls clrify this it's very urget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

If it is so "urget" perhaps you'd consider taking the time to actually type out your words instead of freeze-drying them to unintelligible mumbo-jumbo such as "Pls clrify".

Please read this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downloading a multiple file from server