File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Downloading a multiple file from server" Watch "Downloading a multiple file from server" New topic

Downloading a multiple file from server

anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43

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/" );
response.setHeader("Content-Disposition","attachment; filename=\""+MSG_LVL_NO+"_"+cifId+".xls\"");
response.setHeader("cache-control", "no-cache");
response.setHeader("Pragma","no-cache"); url=new"file://./"+"Download-back/"+MSG_LVL_NO+"_"+cifId+".xls");
File file=new File(url.getPath());
System.out.print("file exist:"+file.exists()); fileInputStream =new;
BufferedInputStream bin=new BufferedInputStream(fileInputStream);

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


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

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

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
Pls clrify this it's very urget
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Downloading a multiple file from server
It's not a secret anymore!