Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloading a multiple file from server

 
anilellendula kumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered zipping the files into one archive?
 
anilellendula kumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,



i am not considering zipping the files on archie.
 
anilellendula kumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Pls clrify this it's very urget
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic