Figured out that changing the encType of form to "application/x-www-form-urlencoded" from "multipart/form-data" resolves this issue. Strange though! Not sure why it didn't work with multipart encryption.
First of all, it's not an encryption, but an encoding. The difference is pretty huge. "Encrypting" is a way of changing the value in such way which is not predictable without having kind of a security key (cipher key, seed, etc). "Encoding" is a way of changing the value in such way that it's acceptable by the data transfer mechanism and/or that it's recognizeable/parseable by the other side without loss of any data. The values are not made unreadable or something, they are just arranged somewhat specific and differently.
Coming back to your concrete problem, the multipart/formdata
encoding is usually only used when you need to be able to send (upload) a file along with the form, using for example <input type="file">
or the RichFaces <rich:fileUpload>
component. The standard application/x-www-form-urlencoded
form encoding, which basically specifies that the request parameters should be sent URL-encoded in this format
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
name1=value1&name2=value2&name3=value3
isn't suitable for passing file contents around. For that the multipart/form-data
encoding should be used which basically look like this:
Content-Type: multipart/form-data;boundary=SOME_BOUNDARY
--SOME_BOUNDARY
content-disposition: form-data;name="name1"
content-type: text/plain;charset=UTF-8
value1
--SOME_BOUNDARY
content-disposition: form-data;name="name2"
content-type: text/plain;charset=UTF-8
value2
--SOME_BOUNDARY
content-disposition: form-data;name="name3"
content-type: text/plain;charset=UTF-8
value3
--SOME_BOUNDARY--
This format allows room for enclosing complete file contents in the request body.
In a JSF 2.0/2.1 web application, multipart/form-data
requests are normally processed by a custom Filter
. In case of RichFaces 3, this is normally processed by the org.ajax4jsf.Filter
which is missing in RichFaces 4.
Note that the application/x-www-form-urlencoded
is already the default encoding type of HTML forms. So you don't need to explicitly specify it yourself. Just omit the enctype
attribute altogether:
<h:form>
</h:form>
and you should be all set.