File upload size / request size restriction?

Splash Forums PrettyFaces Users File upload size / request size restriction?

This topic contains 20 replies, has 5 voices, and was last updated by  userw93 1 year, 5 months ago.

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #26235

    Georgi Cholakov
    Participant

    Situation is: a web application that uses PrettyFaces 2.0.11, JSF 2.2.6, RichFaces 5, JDK 1.7, Tomcat 7. There is a page, that has <h:form enctype=”multipart/form-data”> and its purpose is to upload a file. When no url-mapping in pretty-config.xml is used for this page the file upload works fine without limitations.

    When I put:
    <url-mapping id=”uploadStatistics”>
    <pattern value=”/uploadStatistics/”/>
    <view-id value=”/faces/admin/uploadStatistics.xhtml”/>
    </url-mapping>

    the file upload works still fine with files up to 2MB, but with larger does not.
    Is there a limitation in PrettyFaces for the maximum size of the uploaded file (multipart/form-data) and/or maximum request size? If yes, how to configure it?

    Thanks,
    Georgi Cholakov

    #26238

    No, there isn’t any restriction of the request size. Could you explain “but with larger does not” a bit more? What error do you get?

    #26240

    Georgi Cholakov
    Participant

    I don’t get error, when the file size is greater than 2MB the browser just reload the page and nothing happens, the file is not uploaded nor the button action method is executed. In Tomcat’s log files I found nothing suspicious, no errors or exceptions.

    #26241

    Could you post your full configuration? web.xml and PrettyFaces?

    There is also an FAQ entry regarding file uploads which contains a workaround for Tomcat. See:

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

    #26242

    Georgi Cholakov
    Participant

    web.xml:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app version=”3.0″ xmlns=”http://java.sun.com/xml/ns/javaee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd“>
    <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <context-param>
    <param-name>facelets.SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
    </context-param>

    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

    <env-entry>
    <env-entry-name>jdbcresource</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>jdbc/StockAdvisor</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>languages</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>English, Български</env-entry-value>
    </env-entry>
    <env-entry>
    <env-entry-name>languages_codes</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>en, bg</env-entry-value>
    </env-entry>
    <resource-ref>
    <res-ref-name>jdbc/StockAdvisor</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>

    #26243

    Georgi Cholakov
    Participant

    Here is the picture of pretty-config. Unfortunately I wasn’t able to submit the text because of an error on the picture, even though my reply wasn’t empty.

    Attachments:
    1. pretty-config
    #26245

    Did you try the context.xml entry from the FAQ?

    #26246

    Georgi Cholakov
    Participant

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <Context antiJARLocking=”true” path=”/StockAdvisor” allowCasualMultipartParsing=”true”>
    <Resource …/>
    </Context>

    #26247

    Hmmm. And you say it works without PrettyFaces?

    Could you provide a minimal sample app that reproduces this issue? I guess I will have to take a deeper look at this.

    #26248

    Georgi Cholakov
    Participant

    Yes, it works without url-mapping in pretty-faces config file.
    As soon as I have a little time I will prepare simple app, that reproduces the problem.

    Thanks for your time, Christian.

    #26258

    Georgi Cholakov
    Participant

    I prepared simple application with the discussed issue. Now upload works, but if you uncomment the url-mapping in pretty-config.xml the problem occurs. I’m attaching 3 parts of the project, because its size exceeds 2MB.
    The project is for NetBeans 8.

    #26260

    Georgi Cholakov
    Participant

    First volume.

    #26262

    Georgi Cholakov
    Participant

    Second volume.

    #26265

    Georgi Cholakov
    Participant

    Third volume.

    #26284

    I’m getting CRC errors when unpacking the project.

    Any chance that you provide a Maven project. I don’t have Netbeans installed and I don’t think I can get the project to work without Netbeans. With a Maven project you also don’t have to include all the JAR files which will reduce the file size.

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.

Comments are closed.