Search this site:       RSS Feeds        Facebook
Submit to DeliciousSubmit to DiggSubmit to FacebookSubmit to Google BookmarksSubmit to StumbleuponSubmit to TechnoratiSubmit to TwitterSubmit to LinkedIn

Upload file with Struts 2

Most Recommended Books:      Effective Java      Thinking in Java      Head First Java      Head First Servlets and JSP

This tutorial provides a step by step guide on how to implement upload file functionality with Struts 2 framework. With Struts 2, uploading files is easy to implement since the framework provides fileUpload interceptor which intercepts multipart request and makes uploaded files automatically available for Struts action class.

We are going to build a simple Java web application based on Struts 2 framework using Eclipse IDE. It provides a simple upload form in which the user can pick up a file to upload. The application will be deployed on Tomcat server, and the uploaded file will be copied to a specific directory on the server.

Suppose you have these pieces of software installed on your computer:

Table of content:

1. Setup Eclipse project
2. Configure Tomcat
3. Configure web.xml
4. Configure log4j
5. Configure Struts 2
6. Code upload form
7. Code Struts 2 action class
8. Code result page
9. Test the application
10. References

Attachments:
Download this file (StrutsFileUploader.zip)StrutsFileUploader.zip[Eclipse project]3845 Kb

Additional information