Upload file with Struts 2
- Details
-
Last Updated on 17 September 2012
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:
-
- Struts 2 framework distribution (Download Struts 2.3.4.1).
- Log4J distribution (Download Log4J 1.2.17)
- Eclipse IDE for Java EE Developers (Download Eclipse Juno 4.2).
- Tomcat server (Download Tomcat 7.0).
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
- Prev
- Next >>









