Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request parameter map is always empty for multipart requests #136

Closed
chkal opened this issue Oct 3, 2013 · 6 comments
Closed

Request parameter map is always empty for multipart requests #136

chkal opened this issue Oct 3, 2013 · 6 comments
Assignees
Labels

Comments

@chkal
Copy link
Member

chkal commented Oct 3, 2013

It seems like JSF postbacks don't work in multipart forms:

<h:form enctype="multipart/form-data">
    <h:commandButton value="Click" action="#{bean.action}"/>
</h:form>

This is especially problematic because this enctype is required for JSF 2.2 <h:inputFile>.

Forum reference:

http://ocpsoft.org/support/topic/problem-with-hinputfile/

I did some debugging and it seems that in case of multipart requests HttpRewriteWrappedRequest.getParameterMap() is always empty. Because of this JSF isn't able to find the view state request parameter and so doesn't recognize the request as a postback.

As far as I can tell this is not a JSF specific problem. Instead I guess it happens with any multipart requests.

I'll create a test case to reproduce this.

@ghost ghost assigned chkal Oct 3, 2013
@chkal
Copy link
Member Author

chkal commented Oct 3, 2013

Hmmm. It even doesn't work with PrettyFaces 3.3.3. If I remember correctly, I've already created JSF pages with upload components which were mapped with PrettyFaces. That's weird.

@chkal
Copy link
Member Author

chkal commented Oct 3, 2013

Ups. Seems like this is not a bug. For Tomcat you have to set allowCasualMultipartParsing to true to get it to work correctly.

From the docs:

Set to true if Tomcat should automatically parse multipart/form-data request bodies when HttpServletRequest.getPart* or HttpServletRequest.getParameter* is called, even when the target servlet isn't marked with the @MultipartConfig annotation (See Servlet Specification 3.0, Section 3.2 for details). Note that any setting other than false causes Tomcat to behave in a way that is not technically spec-compliant. The default is false

See: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html

As Glassfish and AS7 are also based on Tomcat, I guess it is the same issue there.

@chkal chkal closed this as completed Oct 3, 2013
@chkal
Copy link
Member Author

chkal commented Oct 3, 2013

I'll keep this one open because we should add this to the FAQ.

@chkal chkal reopened this Oct 3, 2013
@chkal
Copy link
Member Author

chkal commented Oct 4, 2013

I added this to the FAQ:

https://github.com/ocpsoft/rewrite/blob/master/documentation/src/main/asciidoc/faq.asciidoc

It should be avilable here as soon as Redoculous fetches the new content:

http://ocpsoft.org/rewrite/docs/faq

@chkal chkal closed this as completed Oct 4, 2013
@JohnSchneider
Copy link

I'm facing the same issue in Glassfish 4. Everything works perfectly if I disable PrettyFaces mapping. I've tried creating a context.xml with allowCasualMultipartParsing, and tried both deploying with my war, and saving it as a global context.xml in my domain directory. Neither one made any difference.

Any other ideas on how to make this work in Glassfish?

@chkal
Copy link
Member Author

chkal commented Dec 19, 2013

I'm not an expert for Glassfish, sorry. Perhaps you should ask this in the Glassfish forums. I can only tell that allowCasualMultipartParsing solves this problem for Tomcat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants