upload and download all kinds of files in jsp

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.
View Answers

March 26, 2010 at 12:53 PM

we can upload the all type s of files into oracle 10g but when downloading we need mention the type of type(pdf..).....

March 27, 2010 at 11:24 AM

Hi Friend,

The code we have provided you for uploading will upload all kinds of file.Do modification in download.jsp:

<%@ page import="java.util.*,java.io.*"%>
<%@ page import="java.net.*"%>
<%!
public static String getMimeType(String fileUrl)
throws java.io.IOException, MalformedURLException
{
String type = null;
URL u = new URL(fileUrl);
URLConnection uc = null;
uc = u.openConnection();
type = uc.getContentType();
return type;
}

%>
<%
String file=request.getParameter("f");
File f = new File (file);
String filename=f.getName();
String type=getMimeType("file:"+file);

response.setContentType (type);
response.setHeader ("Content-Disposition", "attachment; filename=\""+filename+"\"");

String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();

int bit = 256;
int i = 0;
try {
while ((bit) >= 0) {
bit = in.read();
outs.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
outs.flush();
outs.close();
in.close();
%>

Thanks









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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... link: http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
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   Here is an application that will upload the file and save
Upload and Download in JSP - JSP-Servlet
Upload and Download in JSP  Respected Sir/Madam, I am... 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
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
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
Upload and download file - JSP-Servlet
Upload and download file  What is JSP code to upload and download a document in a web page?  Hi Friend, Try the following code to upload the word document file: 1)page.jsp Display file upload form
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
JSP Upload and Downloading files - JSP-Servlet
JSP Upload and Downloading files  Respected Sir/Madam, Very... and downloading files in JSP, I am facing a problem.. 1) The file name is getting inserted... are fixed one for all types of files what I have uploaded.. I Dont know the exact
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
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
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
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 mp3
upload and download mp3   code of upload and download Mp3 file in mysql database using jsp and plz mention which data type used to store mp3 file in mysql database
common database jsp file for all the jsp files in the application
common database jsp file for all the jsp files in the application  hi... use of this single jsp file while connecting to database rather than writing connectivity code in all the jsp pages . send me the code for that . thanks
Mutliple files upload
Mutliple files upload  Hi Sir, Am doing a project in Jsp and Servlets, i want to upload multiple files inside the grid of the table, and submit... the following link: http://www.roseindia.net/jsp/file_upload
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
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 video
upload and download video  how to upload and download video in mysql databse using jsp? plz give me demo of this with table...   1)page.jsp...;Display file upload form to the user</TITLE></HEAD> <BODY> <FORM
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
Photo upload, Download
Photo upload, Download  Hi I am using NetBeans IDE for developing application for java(Swings). And i am using MySQL as backend database. My... that this photo photo can be accessed in all of the machines from server side
File Upload and Retrive files
File Upload and Retrive files  Can any body help me am getting an error in uploading file. into mysql database.... thank's in advance
Mutliple files upload
Mutliple files upload  <%@page contentType="text/html...","Struts","Hibernet","Springs","JSP","Servlet","JavaScript"); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
Mutliple files upload  <%@page contentType="text/html...","Struts","Hibernet","Springs","JSP","Servlet","JavaScript"); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
Mutliple files upload  <%@page contentType="text/html...","Struts","Hibernet","Springs","JSP","Servlet","JavaScript"); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
Mutliple files upload  <%@page contentType="text/html...","Struts","Hibernet","Springs","JSP","Servlet","JavaScript"); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
Mutliple files upload   <%@page contentType="text/html...","Struts","Hibernet","Springs","JSP","Servlet","JavaScript"); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
How to upload and download file in hadoop?
How to upload and download file in hadoop?  Hi, I am trying to learn to upload the file on the Hadoop HDFS and then download the same file for learning the process. How to upload and download file in hadoop? What
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
java code to upload and download a file - Java Beginners
and Download visit to : http://www.roseindia.net/jsp/file_upload/index.shtml http...java code to upload and download a file  Is their any java code to upload a file and download a file from databse, My requirement is how can i
Jsp Upload
Jsp Upload  <p>multipart\form-data; boundary...; <p>else { </p> <p>out.println("unsucessfull to upload...;<TITLE>Display file upload form to the user</TITLE></HEAD>
how to upload and download images in java?
how to upload and download images in java?  what is the code for uploading and downloading images in java? how do I make a photo gallery through JSP....   Upload and Download images: 1)page.jsp: <%@ page language="java
jsp upload file to server
jsp upload file to server  How to create and upload file to server in JSP?   Find the given example that explains how to upload single and multiple file on server using JSP
Uploading multiple files in JSP - JSP-Servlet
modification I need to do in the code to upload all the files attached. ...Uploading multiple files in JSP  Hi, I have this code in JSP for Uploading multiple files : Samples : Simple Upload
phpmyadmin - upload csv files - SQL
phpmyadmin - upload csv files  i have database in phpmyadmin. i have upload one time in csv file. i need to another csv file in upload same table. i will try to do this but result is failed. (table rows and csv rows are same
upload images - JSP-Servlet
upload images  How to write the jsp code to upload images...://www.roseindia.net/jsp/upload-insert-csv.shtml Thanks... to upload any file therefor it can also upload an image and can insert
File Download in jsp
File Download in jsp  file upload code is working can u plz provide me file download
Image upload file - JSP-Servlet
Image upload file  I want a code for image upload jsp or servlet.  Hi friend, For image upload jsp or servlet visit to : http://www.roseindia.net/jsp/file_upload/employee_upload_profile_image.shtml http
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 different files with same path name but content different, ex,in mails, one
Upload the picture - JSP-Servlet
://www.roseindia.net/jsp/file_upload/employee_upload_profile_image.shtml Thanks RoseIndia...Upload the picture  Dear Sir, How to upload the picture in the database a webpage and i want to show that picture another page. what i
File upload - JSP-Servlet
File upload  I am trying to do a file upload program. But, it shows... ----------------------------------------------------------------------------- Display file upload form to the user <... the file To Upload
upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
upload to database - JSP-Servlet
upload to database  hai friends i have a query that is i have to upload a pdf file into database(sqlserver2000) using jsp. In roseindia some examples i seen that is only for uploading into the server but i need the uploaded file
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... to upload the word file: 1)page.jsp Display file upload form
File upload - JSP-Servlet
File upload  Hello Friends, In my JSP project i want to do a file upload part. For this, i designed two files one for input and other... File Uload Using JSP   Choose the file To Upload
Uploading Multiple Files Using Jsp
to understand how you can upload multiple files by using the Jsp. We should avoid... Uploading Multiple Files Using Jsp  ... a file. In this example we are going to tell you how we can upload multiple files
Photo Upload - JSP-Servlet
for image upload and download using Servle/jsp. Thanks&Regards, VijayaBabu.M  Hi <% //to get the content type information from JSP Request...(); %> You have successfully upload the file by the name
files upload to apache ftp server - Ajax
files upload to apache ftp server  Please, how to upload multiple files to apache ftp server using ajax . I want to upload files using drag drop... line. but I am trying to upload files using ajax. I want you to answer to me

Ads