File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Multipart/form-data  enctype incompatible with file upload? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Multipart/form-data  enctype incompatible with file upload?" Watch "Multipart/form-data  enctype incompatible with file upload?" New topic
Author

Multipart/form-data enctype incompatible with file upload?

Anthony Castillon
Greenhorn

Joined: Nov 30, 2001
Posts: 18
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

Joined: Nov 30, 2001
Posts: 18
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Multipart/form-data enctype incompatible with file upload?
 
Similar Threads
Java Mail Question...
[Help, File Upload encounter OutOfMemoryError]
request.getParameter("fileName") returning null in post method of servlet . Why?
how do i get value from input type file in servlet?
Error uploading file in Mac OS