SIGN UP MEMBER LOGIN:    
ARTICLE

How to Upload Files in JSP

Posted by Vikas Mishra Articles | JSP February 08, 2012
This article shows how to upload files in JSP.
Reader Level:
Download Files:
 

In this article, I am going to develop an application that shows how to upload files in JSP. This example consists of an HTML form, a JSP upload handler, a JSP processor for the uploaded files and another file containing resources.

Here we are going to develop an application showing how to upload files In JSP. To develop this application we use the following steps.

Step 1: Create a New Project.

In this step we select the New Project option from the file menu.

create new project.jpg

Step 2: Choose Project.

In this step we select a web application from the Java web option and then click on the next Button.

select new web application.jpg

Step 3 : Name and Location.

In this step we give it a specific name and set a specific location and click on the next Button.

name.jpg
 

Step 4 : Server and Setting.

We select a specific server for this application and click on the next Button.

server and setting.jpg

Step 5 : Select Framework.

There is no need to select any framework for this application; just click on the finish Button.

selectframework.jpg

Step 6 : Create jsp file.

We create one jsp file for this application.

create new jsp file.jpg

index.jsp

<HTML>
         <HEAD>

         <TITLE>Uploading Files In JSP</TITLE>
         </HEAD>
         <BODY BGCOLOR="cyan">
                 <FORM ACTION="formAction.jsp" METHOD="POST">
                 <INPUT TYPE="FILE" NAME="filer">
                 <BR>
                 <INPUT
TYPE="SUBMIT" VALUE="Submit">
                 </FORM>
         </BODY>
</HTML>

formaction.jsp

<HTML>
         <HEAD>
         <TITLE>
Uploading Files IN JSP</TITLE>
        </HEAD>
         <BODY
BGCOLOR="GREEN">
             <H1>Uploading Files In JSP</H1>
                    File name:
                 <%= request.getParameter("filer") %>
        </BODY>
</HTML>

Step 7: Compile and Run the application.

Now we compile the application and then run it on the server and find the following output.

Output

index.jsp

INDEX.JSP.jpg

First select the file through the browser and click on the submit Button.

2.jpg


formaction.jsp

formaction.jpg

Resources related to this article

Login to add your contents and source code to this article
Article Extensions
Contents added by Narendrain Dutta on Mar 30, 2012
<html>
share this article :
post comment
 

but how do you process and store the uploaded file?

Posted by test test Feb 09, 2012
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Team Foundation Server Hosting
Become a Sponsor