Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 upload image problem

 
Robert Sacchi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!
I need to upload an image file using struts 2.
I just follow step by step the example in this site

but when I'm on action java class, I always get my upload variables NULL (in my case userImage, userImageContentType and userImageFileName).

I've copied "commons.fileupload-1.2.2.jar" and "commons.io-2.4.jar" into my WEB-INF/lib folder.
I try to change something to make it works, so here's my struts.xml:



The strange thing is that I get no feedback at all, no errors... I reach the success.jsp page but with userImage = null.
Maybe interceptors don't do their job.

Any help?

Thanks

Rob
 
Robert Sacchi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone could build a dynamic eclipse project, try the example I link and tell me if it works?
I'm sure I'm missing something, but I don't know how to find it.

Thanks

Rob
 
Robert Sacchi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry If I update this thread again, but I've discovered something probably useful.
I'm using Glassfish 3.1.2 as Server, and when I submit the form, the image is stored in this directory:

c:/glassifish3/glassfish/domains/domains/generated/jsp/MYPROJECT

That file is deleted after the action execution.
So Struts 2 doesn't see that directory...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic