I am running into a problem that I cannot seem to remedy. I have a
product called jupload installed (http://jupload.biz/) and the applet
shows up in the browser and the JavaServer Faces method gets called
correctly, but when I do the "fileupload.parseRequest(request)" in the
code below I always get an empty List object (meaning no entries are
returned).
I can see the document I am trying to upload in the HTTPServletRequest
variale (request) just fine in debug mode. Anybody have ideas of why
this might not be working? I am using Tomcat 5.5.9 and MyFaces 1.0.7.
I am posting it in the MyFaces forum to see if MyFaces would affect
anything that would prevent me from being able to get a list of the
objects being uploaded. I read in a different forum that the
parseRequest() method can only be called once per request. If it is
called a second time the results will not be returned. Is this true?
Thanks in advance for any help that can be offered,
Aaron Bartell
<applet
code="JUpload/startup.class"
archive="jupload.jar"
width="650"
height="400">
<param name="actionURL"
value="http://localhost/LDDT/massupload.jsf">
<param name="boxbgcolor" value="#ffffff">
<param name="backgroundColor" value="#ffffff">
<param name="image" value="">
<param name="showPicturePreview" value="false">
<param name="addWindowTitle" value="File Upload">
<param name="debug" value="true">
<param name="debugLogfile" value="/jupload.log">
<param name="checkJavaVersion" value="true">
<param name="showErrorsOnAdd" value="true">
</applet>
This is the [URL]http://localhost/LDDT/massupload.jsf[/URL] page's code:
<f:view>
<h:form id="loginForm">
<h:outputText value="#{MassUploadCtl.processUpload}"
rendered="true"/>
</h:form>
</f:view>
Here is the method that is called from the massupload.jsf page at page
execution time.
public String getProcessUpload() {
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)
fc.getExternalContext().getRequest();
String location = "\\";
boolean isMultipart = FileUpload.isMultipartContent(request);
if (isMultipart) {
DiskFileUpload fileupload = new DiskFileUpload();
List fileitems = null;
try {
[B]fileitems =
fileupload.parseRequest(request);[/B]
Iterator iterator = fileitems.iterator();
while (iterator.hasNext()) {
FileItem fileitem =
(FileItem) iterator.next();
if (fileitem.isFormField()) {
System.out.println("Received field with name ");
System.out.println(fileitem.getFieldName());
System.out.println(" and content ");
System.out.println(fileitem.getString());
} else {
System.out.println("Received file ");
System.out.println(fileitem.getName());
System.out.println(" with a total size of ");
System.out.println(fileitem.getSize());
System.out.println(" bytes and content type ");
System.out.println(fileitem.getContentType());
}
}
} catch (FileUploadException e) {
e.printStackTrace();
}
} else {
System.out.println("No multipart upload found.");
}
return null;
}