Ciao a tutti,
Devo fare un upload di un file, e stò usando la classe MultipartRequest multi = new MultipartRequest(request,".");
il codice della pagina jsp contenente il form questa:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.io.*" import="java.sql.*" import="java.lang.*" import="javax.servlet.*" errorPage=""%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<FORM NAME="form" METHOD="POST" ACTION="Upload"
ENCTYPE="multipart/form-data">
<INPUT TYPE="text" NAME="file2" SIZE=15>
<INPUT TYPE="FILE" NAME="file1" SIZE=15>
<INPUT TYPE="SUBMIT" NAME="SEND" VALUE="Send">
</FORM>
</body>
</html>
invece il codice della servlet e questo:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String prova=request.getParameter("file2");
out.println(prova);
MultipartRequest multi = new MultipartRequest(request,".");
String provetta=multi.getParameter("file2");
File f = multi.getFile("file1");
String filename=multi.getFilesystemName("file1");
System.out.println(filename);
if(f!=null){
File fOUT= new File("C:\\Documents and Settings\\DIEGO\\Desktop\\eclipse\\Due\\file",file name);
FileInputStream fIS=new FileInputStream(f);
FileOutputStream fOS=new FileOutputStream(fOUT);
while(fIS.available()>0)
fOS.write(fIS.read());
fIS.close();
}
------------------------------------------
il problema avviene quando lancio la servlet e mi ritorna un errore di questo tipo:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: com/oreilly/servlet/MultipartRequest
prova.Upload.doPost(Upload.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.
non riesco a capire dove stà il problema e pure il codice in teoria dovrebbe essere tutto giusto.
Viringrazio anticipamente.