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



Home Answers Viewqa JSP-Servlet JSP file download

Have Programming Question? Ask it here!
 
 
 


vasu
JSP file download
1 Answer(s)      5 years and 3 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

May 13, 2009 at 2:42 PM


Hi Friend,

If you have saved your word/pdf/image file content into a blob type object in the database then you can try the following code to download word file:

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="javax.servlet.*"%>
<%
ServletOutputStream output = response.getOutputStream();
String connectionURL = "jdbc:mysql://192.168.10.112:3306/file";;;
String Content=new String("");
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection(connectionURL,"root","root");
Statement st=con.createStatement();
ResultSet rst= st.executeQuery("select file_data from file ");
if(rst.next())
{
Content=rst.getString("file_data");
}
con.close();
}catch(Exception e){
System.out.println("Exception caught"+e.getMessage());
}
byte requestBytes[] = Content.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(requestBytes);
response.reset();
response.setContentType("application/doc");
response.setHeader("Content-disposition","attachment; filename=" +"Wordfile.doc");
byte[] buf = new byte[1024];
int len;
while ((len = bis.read(buf)) > 0){
output.write(buf, 0, len);
}
bis.close();
response.getOutputStream().flush();
%>

For more information, visit the following link:

http://www.roseindia.net/jsp/downloadcsv.shtml

Thanks


Related Tutorials/Questions & Answers:
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
Advertisements
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... to download word file: <% ServletOutputStream output
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
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Ragavendran, i am sending code of file download in jsp. Plz implement this code. file download in jsp
Capture browser file download event - JSP-Servlet
Capture browser file download event  Hi, I appreciate your help and thaanks for that.But my question was when filedownload dialog box comes in browser,how we can come to know that user has clicked on Open,save or cancel button
file download
file download  I uploaded a file and saved the path in database. Now i want to download it can u plz provide code
how to create xls file and give download option using jsp/servlet?
how to create xls file and give download option using jsp/servlet?  Hi, how to create file and give download option to user,so that the user can save the file on defined path
File download from server to client machine - JSP-Servlet
File download from server to client machine  hi, I want to save a pdf file to my client machine from a button provoded in a jsp page.The file that was generated by jasper libraries.In my code i can give path for save
php download file script
php download file script  PHP script to download file in IE
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... : Download the CSV File : Download the application
Download PDF file
Download PDF file  How to download PDF file with JSF
php download file code
php download file code  PHP code to download the files from the remote server
how to download file
how to download file  How do I let people download a file from my page
php download file browser
php download file browser  limiting downloading file system via browser only through my web application
Download a file - Java Beginners
Download a file   Hi, I need a java code to download a file from a website and before downloading it should give me an option to browse and select the location to put the file. Thanks in advance
csv file download
csv file download  Hello Every one, when user clicks download button I want to retrieve data from mysql database table in csv format using java.if... the following link: JSP Retrieve data from MySQL Database
File Download Security
File Download Security   Hello, I trying to create an application in PHP to prevent or provide file download security. So, I need the help of senior... files downloading. Please read this article about File Download Security
file download in struts - Struts
file download in struts  Hello... I've designed an application where i need to download an xml file by creating it... so...i used dom for it.. I... an xml file from database.. Everything's going on well... Now what my problem is i
how to download a file from a folder??
how to download a file from a folder??  i can upload any kind of files to a folder, and only the path of the file is saved into the database, now how a client can download the file from my folder. pls provide me the jsp code
download mp3 file on server in iphone
download mp3 file on server in iphone  I want to download mp3 file on the server in iphone......plz help me give me the demo code
php download file from url
php download file from url  how to download multiple files in PHP using the URL's
php download file from ftp
php download file from ftp  Need to download files from ftp using php. a simple example
upload and download a file - Java Beginners
upload and download a file  how to upload a file into project folder in eclipse and how to download the same using jsp   Hi Friend, Try the following code: 1)page.jsp: Display file upload form to the user
Uploading and download pdf or .txt file.
Uploading and download pdf or .txt file.  I want admin user to upload pdf file into database and the users can download those pdf format from database
download - JSP-Servlet
download  here is the code in servlet for download a file. while downloading the file the file is getting downloaded but content is not present... code you have written is just creating a file with the same name for download
Upload and Download in JSP - JSP-Servlet
and downloading a file in JSP.. When the admin clicks upload, he must be able to upload.... Please visit for more information. http://www.roseindia.net/jsp/file_upload...Upload and Download in JSP  Respected Sir/Madam, I am
file upload download - Java Beginners
file upload download  how to upload and download files from one system to another using java.io.* and java.net.* only please send me code
upload and download files - JSP-Servlet
and download files in JSP visit to : http://www.roseindia.net/jsp/file_upload...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
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
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
java/jsp code to download a video
java/jsp code to download a video  how can i download a video using jsp/servlet
java code to upload and download a file - Java Beginners
and Download visit to : http://www.roseindia.net/jsp/file_upload/index.shtml http... to upload a file and download a file from databse, My requirement is how can i..., one user send one a.doc file to x ,he has to download his a.doc another
download image using url in jsp
download image using url in jsp  how to download image using url in jsp
File download security.
File Download Security  This script prevents the file to be linking to other file as this script force the file to be downloaded well before...; In this script, filter_var() is used for filtering the file and valid
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
download a file from browser - Java Beginners
download a file from browser  How to download a file from browser and save it in local path
File download return value - Java Beginners
File download return value  How to get the return value of Open/Save/Cancel buttons in a File Download pop up using javascript
how to create a php script to download file
how to create a php script to download file  php script to download file
code to upload and download a file - Java Magazine
code to upload and download a file  Is their any code to upload a file and download a file from databse, My requirement is how can i store two... user send one a.doc file to x ,he has to download his a.doc another user sends
upload ,download and update file document - JDBC
upload ,download and update file document   hi sir.i am creating one application in jsp in which i need to upload the word document file which...();} } %>  continue........ Now to download the word file, try
download file Error in struts2 action class
download file Error in struts2 action class  Hi, i am using bellow block of code for download file : public void downloadGreeting(String... strPrefix = System.getProperty("astsoundsfolderoriginal"); File
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
Download.
Download.  I need a swing program to download a file from the server
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
URL file Download and Save in the Local Directory
URL file Download and Save in the Local Directory       This Program file download  from  URL and save this Url File in the specified directory. This program specifies
JSP Excel report download for .xlsx format
JSP Excel report download for .xlsx format  <%@ page contentType...; The above code works fine because i am trying to save/open excel file in .xls format but my requirement is to download excel with format .xlsx (m.S 2007),so i changed
Download
Download JDK  How to Download the latest Version of JDK?   Download OST to PST converter from: http://www.osttopst.info
download
download  how to download the file in server using php code: "<form method="post" action=""> enter the folder name<input type="text" name="t1" > <input type="submit" value="search" name="s1"> </form> <
JSP File
JSP File  Hi, What is JSP File? How to create JSP file? Thanks   Hi, JSP file is simple text file with .jsp extenstion. You can run JSP file on tomcat server. Read more at JSP tutorials section. Thanks
Advertisements
 

 

 

DMCA.com