• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

struts 2 - fileUpload interceptor problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

My problem is when I use the fileUpload interceptor. When I add the interceptor to the action, the File object in the form bean comes out as null. Meaning it wasnt uploaded. If I take out the interceptor, the file does get uploaded and the File object is not null and everything works normally. Even when I have no parameters for the interceptor such as "allowedTypes" and "maximumSize", the file still does not load the File object in the form bean in struts 2. What is the correct way to use this interceptor? I have marked the line in the struts.xml shown, which when taken out, allows everything to work fine.

thanks in advance for your assistance
---------------------------------------------------------------------------
<package name="tutorial" extends="struts-default">

<interceptors>
<interceptor name="fileUpload" class="org.apache.struts2.interceptor.FileUploadInterceptor">

</interceptor>
</interceptors>

<action name="UploadPic" class="pic.Upload">
<interceptor-ref name="fileUpload"/> ***(this line taken out works fine, with this line File object becomes null)***
<result name="input">Error.jsp</result>
<result>/WEB-INF/ShowPic2.jsp</result>
</action>

</package>
---------------------------------------------------------------------------
 
Author
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The fileupload interceptor is already in the default stack, which your action inherits automatically since your package extends struts-default.

Actually, by defining that interceptor reference for your action, you are replacing the full default stack with just that single interceptor. Basically, as you have it, you've removed all of the default interceptors and replaced them with one; and it can't do even it's job without the others.

In short, you can fix this just by getting rid of that interceptor reference in your action.

Our book tells all about how to handle interceptor stack configuration
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic