Uploading files in Struts

Uploading files in Struts
Struts has default interceptor (in-build interceptor) for uploading files, however not that these files will get stored in temporary directory they should be processed and stored in permanent location.  (Refer: Default Interceptors in Struts)

Lets see an example of uploading an image using Struts,

Directory Structure
Structure

We have created 2 jsp files, one dao.java for this example.

upload.jsp

success.jsp

dao.java

struts.xml

Output:
op1
op2
Uploaded Successfully!

Now check server.log to know the location where the image got saved,

Image Location: E:\NetBeans\Struts2FUL\build\web\images

 

op4

 

 

 

 

Read More