You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

Component Overview

Commons-FileUpload makes it easy to add robust, high-performance, file upload capability to your servlets and web applications.

A lot of information is available on the FileUpload website. If you don't find the information you need you can always contact us using one of the mailing lists.

External Resources

If you have a good example, add it here!

FAQ

Add your questions/answers here.

Q: When parsing a multipart request that exceeds the maxSize or if a file exceeds the maxFileSize, is there any way to drop the file/files from the parsing process and still return the field items?

I though of putting the field items in the query string but haven't tested it. Even if it would work, it wouldn't be a handsome solution!

Q: I'm using a DiskFileItemFactory from FileUpload 1.2.1. In the Resource Cleanup section of the User Guide, the following code is shown:

return new DiskFileItemFactory(fileCleaningTracker,

DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD,

repository);

This method doesn't actually exist (with the implied signature), so instead, I've done the following:

DiskFileItemFactory factory = new DiskFileItemFactory();

factory.setFileCleaningTracker(fileCleaningTracker);

Is this how it should be done now?

Q: I'm using FileUpload 1.1.1,when I use ServletFileUpload.isMultipartContent(request).This is said "Use the method on ServletFileUpload instead".But I can't find "isMultipartContent" method in ServletFileUpload........

Q: How do you use FileUpload in a JSR168 JSF portlet ?

Q: Very often when we try to upload a file (several types such as jpeg, ppt etc.) we get an error message from Internet-Explorer "page cannot be displayed"

Not always but very often (absolutely not reliable). We don't see any error messages, neither in apache nor in tomcat (as if there had been no request at all).

Apache is configured to redirect all non-SSL request to SSL, but I think that shouldn't cause any problems because that happens only once (the user must first log-in, then go through several dialogs before he can upload, thus the redirection is done much earlier).

Except that, everything is very stable.

Any ideas?

A: The reason was Internet Explorer needs the following in Apache:

SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \

downgrade-1.0 force-response-1.0

Zsolt

Q: I use commons.fileupload to upload a file in my application, but it throws an exception called "NotSerializableException", the server which the application run on is WAS5.1 and struts 1.2.4. Here is the output log:
[06/05/15 19:15:36:873 JST] 78adaa3 [SessionContex] E 例外: java.io.NotSerializableException: org.apache.commons.fileupload.DeferredFileOutputStream
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java(Inlined Compiled Code))
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java(Inlined Compiled Code))
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java(Inlined Compiled Code))
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java(Inlined Compiled Code))
at java.util.Hashtable.writeObject(Hashtable.java(Compiled Code))
at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java(Compiled Code))
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java(Compiled Code))
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.BackedHashtable.commonSetup(BackedHashtable.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.BackedHashtable.persistSession(BackedHashtable.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.BackedHashtable.ejbStore(BackedHashtable.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.BackedHashtable.storeSession(BackedHashtable.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.BackedHashtable.put(BackedHashtable.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.DatabaseSessionContext.sync(DatabaseSessionContext.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.SessionData.sync(SessionData.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.httpsession.DatabaseSessionData.sync(DatabaseSessionData.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.httpsession.DatabaseSessionContext.checkForSessionWrites(DatabaseSessionContext.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.DatabaseSessionContext.asyncExternalWrite(DatabaseSessionContext.java(Compiled Code))
at com.ibm.ws.webcontainer.httpsession.SessionAlarmListener.alarm(SessionAlarmListener.java(Compiled Code))
at com.ibm.ejs.util.am._Alarm.run(_Alarm.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

Can anyone give me some idea to solve this question?

  • No labels