Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Re:number of Files download problem in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


pradeep
Re:number of Files download problem in jsp
0 Answer(s)      4 years and 4 months ago
Posted in : JSP-Servlet


I write code for single file downloading , but I want to download number of files at same time , means I want stored number of files in one temp zip file then it download it. please help in this case ...
code :

<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.BufferedInputStream" %>
<%@ page import="java.io.File " %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.util.*" %>

<%
String dwFilename ="C:\\downloadJSP\\raj.zip";
response.addHeader("Content-Disposition","attachment; filename="+dwFilename );
// 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( );


}
%>

<p>Files: <%=dwFilename%></p>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Re:number of Files download problem in jsp - JSP-Servlet
Re:number of Files download problem in jsp  I write code for single file downloading , but I want to download number of files at same time , means I want stored number of files in one temp zip file then it download it. please
Upload and Download Large files in jsp
Upload and Download Large files in jsp  I am not able to download large files (>200mb) from any server. I need a code to download and upload large files (atleast 4 gb) to a server using jsp page
Advertisements
upload and download files - JSP-Servlet
upload and download files  HI!! how can I upload (more than 1 file) and download the files using jsp. Is any lib folders to be pasted? kindly... and download files in JSP visit to : http://www.roseindia.net/jsp/file_upload
how to download the uploaded folder files using jsp
how to download the uploaded folder files using jsp  how to download the uploaded folder files using jsp
Problem in downloading files - JSP-Servlet
Problem in downloading files  Hi, i have uploaded some files using its uploading successfully. but when downloading the same file, its giving...:148) at org.apache.jsp.downloadfile_jsp._jspService(downloadfile_jsp.java:146
download pdf files
download pdf files  pls help me,I don't know how to convert .doc,.docx files into pdf files and download that pdf files using servlet or jsp
upload and download all kinds of files in jsp - Java Beginners
upload and download all kinds of files in jsp  how to upload and download all kinds of files ex: image file,pdf,.xls in jsp. your help is highly appreciated.  we can upload the all type s of files into oracle 10g
Creat a folder, inside it upload and download files in jsp and mysql
Creat a folder, inside it upload and download files in jsp and mysql  Create one or more folder .inside it we can upload and download multiple files... to database. The uploaded files will then displayed on the browser and will allow the user
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc... using jsp with sqlserver ,can you please provide a proper coding for it and also
How to download files from server to local disk using ZIP format in JSP page - JSP-Servlet
How to download files from server to local disk using ZIP format in JSP page  hi i have an application to upload and download multiple files. As i can upload multiple files .now i have to download all uploaded files on local
Upload and Download in JSP - JSP-Servlet
and downloading a file in JSP.. When the admin clicks upload, he must be able to upload files and similarly when the user clicks the download option, he must be able...Upload and Download in JSP  Respected Sir/Madam, I am
download or save jsp page
download or save jsp page  hii.., this is my jsp page .. This page is theater ticket. i want to download this page. so i need to save this page or download.. that depend on user wish how to make this page save or download <
download or save jsp page
download or save jsp page  hii.., this is my jsp page .. This page is theater ticket. i want to download this page. so i need to save this page or download.. that depend on user wish how to make this page save or download <
File Download in jsp
File Download in jsp  file upload code is working can u plz provide me file download
Download file - JSP-Servlet
Servlet download file from server  I am looking for a Servlet download file example
JSP file download - JSP-Servlet
JSP file download  Hi! I am saving (webapp/docs/sample.docx) path of the word file in database. when i want to download that file i am eliminating... on the link it is asking open or save. Upto this is fine..... I want to download
setting path problem for org.jfree files - Java Beginners
have those classes which you have import. Download the following jar files...setting path problem for org.jfree files  Hi deepak, As u said, i have downloaded two files jar files and placed them in lib folder to work
Download dynamic link files to local directory - java code
Download dynamic link files to local directory - java code  Hi, I found a code that downloads static links but not dynamic link files.can anyone give a solution for downloading dynamic link files? Thanks in advance
Download LINK - JSP-Servlet
Download LINK  sorry i am the new1 to java. I am learning and doing the project, can you please send me the complete code. So that i can understand easily. i want the code like by Clicking DOWNLOAD button the SAVE as dialog box
download - JSP-Servlet
download  here is the code in servlet for download a file. while...; /** * * @author saravana */ public class download extends HttpServlet...(); System.out.println("inside download servlet"); BufferedInputStream
Download Button - JSP-Servlet
Download Button  HI friends, This is my maiden question.... And i want the Bank customers to DOWNLOAD the mini statement. Can any one help me how to implement the download button so that on clicking that the mini
upload and download files from ftp server using servlet - Ajax
upload and download files from ftp server using servlet  Hi,Sir Sorry for my complex questions. My problem is that I don't know client side script for upload and download files from ftp server using servlet and how to use
java/jsp code to download a video
java/jsp code to download a video  how can i download a video using jsp/servlet
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Download in JSP.. In the Admin window, There must be "Upload" provision where admin can upload files.. And in the user window, There must be a "Download" provision
download image using url in jsp
download image using url in jsp  how to download image using url in jsp
org.jfree package download - JSP-Servlet
org.jfree package download  I saw a code in roseindia but that code requires a package "org.jfree.chart.*" and "org.jfree.ui.*" Please give me the packages .  Hi friend, Plz download the jar files
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Upload and download file - JSP-Servlet
Upload and download file  What is JSP code to upload and download............ Now to download the word document file, try the following code...(); response.getOutputStream().flush(); %> Thanks   I want to download a file
Download CSV File from Database in JSP
Download CSV File from Database in JSP  ... to download CSV  file from database in JSP.  In this example, we have developed two files "viewcsv.jsp" and "file_download.jsp" , code
 

 

 

DMCA.com