Hola :)
Tengo un problema que no se que puede ser, debo estar haciendo algo mal...
trato de subir un archivo excel mediante jsp, pero al parecer no lo toma bien...
Código C:
Ver originalif (ServletFileUpload.isMultipartContent(request))
{
if(request == null)System.out.println("***ES NULOOOO***");
System.out.println("***ENTRO SERVLETFILEUPLOAD***");
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
FileItem fileItem = null;
List fileItemsList = servletFileUpload.parseRequest(request);
String optionalFileName = "";
fileItem = null;
Iterator it = fileItemsList.iterator();
if(fileItemsList.isEmpty()) System.out.println("***COLECCION ES NULA***");
while (it.hasNext()){
FileItem fileItemTemp = (FileItem)it.next();
System.out.println("***ENTRO HASNEXT***");
if (fileItemTemp.isFormField()){
%>
<b>Name-value Pair Info:</b><br/>
Field name: <%= fileItemTemp.getFieldName() %><br/>
Field value: <%= fileItemTemp.getString() %><br/><br/>
<%
if (fileItemTemp.getFieldName().equals("filename")) {
optionalFileName = fileItemTemp.getString();
System.out.println("***ARCHIVO***: " + fileItem.getFieldName());
}
else
System.out.println("***ENTRO ELSE GETFIELDNAME***");
}
else
fileItem = fileItemTemp;
}
if (fileItem!=null){
String fileName = fileItem.getName();
System.out.println("***ENTRO IF FILEITEM***");
%>
<b>Uploaded File Info:</b><br/>
Content type: <%= fileItem.getContentType() %><br/>
Field name: <%= fileItem.getFieldName() %><br/>
File name: <%= fileName %><br/>
File size: <%= fileItem.getSize() %><br/><br/>
<%
if (fileItem.getSize() > 0){
System.out.println("***ENTRO IF GETSIZE***");
if (optionalFileName.trim().equals("")) {
System.out.println("***ENTRO IF OPTIONALFILENAME***");
fileName = FilenameUtils.getName(fileName);
}
else{
System.out.println("***ENTRO ELSE PRIONALFILENAME***");
fileName = optionalFileName;
}
String dirName = "/file_uploads/";
File saveTo = new File(dirName + fileName);
fileItem.write(saveTo);
}
} else{
System.out.println("***ENTRO ELSE FILEITEM***");
}
}
Esto Imprime::
***ENTRO SERVLETFILEUPLOAD***
***COLECCION ES NULA***
***ENTRO ELSE FILEITEM***
Alguna idea?
Algun otro script? :(
Necesitan algun otro codigo?
Agradecido de ante mano