File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes File Uploading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File Uploading" Watch "File Uploading" New topic

File Uploading

Joe Ridener
Ranch Hand

Joined: Jul 16, 2012
Posts: 86

I am in the middle of a tutorial on Struts II. Although I have gone all over trying to get this program up and running I am still having the same exact problem and would have to believe that it is common. The error is that the it is not setting the File object in my sub-class of ActionSupport. my server console almost always says

INFO: Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir

My Struts XML says this:

My Java Source code

I just threw this together very quickly. In previous attempts i followed the fileUpload's naming conventions far more strictly and still had the same result. So even though many of you may mention this it is most likely not the problem.
Joe Ridener
Ranch Hand

Joined: Jul 16, 2012
Posts: 86
Oh yeah I forgot to mention that the File object is always null and does not exist.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
I know little about Struts, but my first check would be that "javax.servlet.context.tempdir" points to a directory that can be read and written by whatever user account the servlet container runs under, and that no security manager interferes with that.
Joe Ridener
Ranch Hand

Joined: Jul 16, 2012
Posts: 86
Close ... turned out the problem was you have to nest the interceptor-ref's a certain way. But my program does run now. And yes I created an images directory and download to there and it is better.

It is sorta covered in the JavaRanch Style Guide.
subject: File Uploading
It's not a secret anymore!