3 Replies Latest reply on Mar 17, 2008 8:19 PM by kosl

    Problems with fileUpload

    kosl

      Dear All!


      I'm having problems with fileUpload tag. First of all I have the following entry in my components.xml file:



      
      <component class="org.jboss.seam.web.MultipartFilter">
        <property name="createTempFiles">true</property>
        <property name="maxRequestSize">10</property>
      </component>
      



      As I expect only requests of size up to 10 bytes should be allowed, but in fact that is not true. I can upload a file of 50, or even 100 KB.


      Any clues about why this entry is ignored?


      Another question is, about what if this above worked? Is there any way of detecting files bigger then allowed (before uploading them) and showing a message to user? I've tried to use the exception intercepting in pages.xml but with it I can redirect all fileupload exceptions to one fixed page, and what I would like to achieve is redirecting to the same page where fileUpload tag is present, and showing a message. (I have fileUpload tag on more than one page in my application).


      Thanks in advance for any help.


      Karol


      PS:


      relevant parts of my web.xml:



           <listener>
                <listener-class>
                     org.jboss.seam.servlet.SeamListener
                </listener-class>
           </listener>
      
           <servlet>
                <servlet-name>Seam Resource Servlet</servlet-name>
                <servlet-class>
                     org.jboss.seam.servlet.SeamResourceServlet
                </servlet-class>
           </servlet>
           <servlet-mapping>
                <servlet-name>Seam Resource Servlet</servlet-name>
                <url-pattern>/seam/resource/*</url-pattern>
           </servlet-mapping>
      
           <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>*.html</url-pattern>
           </servlet-mapping>
      
           <filter>
                <filter-name>Seam Filter</filter-name>
                <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
           </filter>
           <filter-mapping>
                <filter-name>Seam Filter</filter-name>
                <url-pattern>/*</url-pattern>
           </filter-mapping>
      
           <filter>
                <display-name>Ajax4jsf Filter</display-name>
                <filter-name>ajax4jsf</filter-name>
                <filter-class>org.ajax4jsf.Filter</filter-class>
                <init-param>
                     <param-name>forceparser</param-name>
                     <param-value>false</param-value>
                </init-param>
           </filter>
           <filter-mapping>
                <filter-name>ajax4jsf</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                <dispatcher>REQUEST</dispatcher>
                <dispatcher>FORWARD</dispatcher>
                <dispatcher>INCLUDE</dispatcher>
           </filter-mapping>
      
      


        • 1. Re: Problems with fileUpload
          shane.bryzak

          MultipartRequest looks for a header value for Content-Length, and compares it to the configured max request size.  I suggest you set a breakpoint in the constructor for MultipartRequest to see what's happening.

          • 2. Re: Problems with fileUpload
            kosl

            Dear Shane,


            I did what you suggested and not surprisingly it looks like MultipartRequest aint seeing the configuration parameters from the components.xml file which I have shown in my previous post. The createTempFiles variable is always set to false and maxRequestSize is fixed to the value 1000000.


            I would be grateful for any other suggestions.


            Kind Regards,

            • 3. Re: Problems with fileUpload
              kosl

              It looks like I solved the problem. In my components.xml I had such entries:



              <component class="org.jboss.seam.web.MultipartFilter">
                <property name="createTempFiles">true</property>
                <property name="maxRequestSize">0</property>
              </component>
              


              but also:


              <web:multipart-filter create-temp-files="false" max-request-size="1000000"/>



              which seems to set the same values. I was changing only the first one and that was the cause of problems. Sorry for disturbing and thanks for advice with debugging.


              Regards,