ok ya va que yo no entiendo mucho JAVA; este es el uploadfile.java
Código JAVA:
Ver originalpackage ve.gob.fii.web;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileItem;
@SuppressWarnings({ "deprecation", "serial" })
public class uploadFile extends HttpServlet {
/**
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
System.out.println("<html>");
System.out.println("<head>");
System.out.println("<title>Servlet</title>");
System.out.println("</head>");
System.out.println("<body>");
System.out.println("Comenzamos procesamiento ficheros");
procesaFicheros(request,out);
System.out.println("</body>");
System.out.println("</html>");
out.close();
}
{
System.out.println("El error es " + cadena);
}*/
}
public boolean procesaFicheros
(HttpServletRequest req,
PrintWriter out
) {
try {
System.
out.
print("El numero de ficheros su");
DiskFileUpload fu = new DiskFileUpload();
fu.setSizeMax(1024*512); // 512 K
System.
out.
print("El numero de ficheros su");
depura("Ponemos el tamaño máximo");
fu.setSizeThreshold(4096);
System.
out.
print("El numero de ficheros su"); fu.setRepositoryPath("/tmp");
System.
out.
print("El numero de ficheros su");
List fileItems
=fu.
parseRequest(req
);
if(fileItems==null)
{
System.
out.
print("El numero de ficheros su");
depura("La lista es nula");
return false;
}
System.
out.
print("El número de ficheros subidos es: " + fileItems.
size());
FileItem actual=null;
//depura("estamos FileItem actual = null;en la iteración");
while (i.hasNext())
{
actual = (FileItem)i.next();
String fileName
= actual.
getName(); System.
out.
println("<br> Nos han subido el fichero: " + fileName
);
actual.write(fichero);
}
}
depura("Error de Aplicación " + e.getMessage());
return false;
}
return true;
}
}
y este mi web.xml
Código java:
Ver original<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>tilesExample</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml,/WEB-INF/dispatcher-conection.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
tambien tengo un dispatcher-servelt.xml, un dispatcher-conection.xml y un tile-defs.xml