Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multipart/form-data enctype incompatible with file upload?  RSS feed

 
Anthony Castillon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with a jsp-based form built using JSF, particularly MyFaces and Tomahawk. I am using <t:inputFileUpload> to display a file input component in the jsp page. After clicking the Save button, the backend code kicks in to process the uploaded file and other input parameters successfully and then gets ready to redisplay the same page.

However, there is another jsp that is included (using <jsp:include>)in this main jsp page as well as parameters (via <jsp:param> with set values) that are nested inside the <jsp:include>.

The included jsp reads the parameters that are passed on to it from the main jsp. The problem is that these parameters return null values and causes a NullPointerException during runtime.

I have the enctype="multipart/form-data" attribute in my form since I am working with the file input. However, I read about JSF problems handling parameters in included jsp's when the enctype is "multipart/form-data" but I could not find a good solution. When I remove the enctype attribute from my form, there is no problem in my page navigation.

Right now, I'm using the following files:
tomahawk_1.1.6.jar
commons-fileupload-1.2.1.jar

I'd appreciate any help on this matter.
 
Anthony Castillon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanna put some closure to this thread:

I resolved my issue by doing the following:
1. In the form jsp with the file upload input item, I added a scriptlet which created a session-scope object. For my purpose, the value of the object did not really matter.
2. In the included JSP, I added code to check if the parameters that were supposed to be passed from the form jsp. If they have null values, I check for the session object. If it exists, I set the parameters to some values (that should have been passed by the form jsp when the Save button is clicked). Then, I remove the session object.

It was a hack to do away with the problem with the inputFileUpload tag.

Anthony
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!