S
sebek
Hello!
First, I`n new...
I want make upload file. I find some library: cos,
jakarta...fileupload, uploadbean.
I choose Jakarta. It`s a good choice?
Second. Code service should bo in: public void
doPost(HttpServletRequest
request, HttpServletResponse response) throws ServletException,
IOException? Maybe it`s stupid question butI have error:
type Exception report
message
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
javax.servlet.ServletException: Invoker service() exception
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:477)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoClassDefFoundError:
org/apache/commons/io/output/DeferredFileOutputStream
org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:179)
org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:116)
lectures.PageAdd.doGet(PageAdd.java:67)
lectures.PageAdd.doPost(PageAdd.java:121)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
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.
A oto fragment kodu który jest umieszczony w metodzie doPost:
This is the code what I have in method doPost:
boolean isMultipart =
FileUpload.isMultipartContent(request);
DiskFileItemFactory factory = new
DiskFileItemFactory();
// Configure the factory here, if desired.
ServletFileUpload upload = new
ServletFileUpload(factory);
// Configure the uploader here, if desired.
List items = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
//processFormField(item);
} else {
//processUploadedFile(item);
}
}
It`s take from Jakarta. (example)
And one, how can I read value varaible which is sending from form?
Great Thanks!
First, I`n new...
I want make upload file. I find some library: cos,
jakarta...fileupload, uploadbean.
I choose Jakarta. It`s a good choice?
Second. Code service should bo in: public void
doPost(HttpServletRequest
request, HttpServletResponse response) throws ServletException,
IOException? Maybe it`s stupid question butI have error:
type Exception report
message
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
javax.servlet.ServletException: Invoker service() exception
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:477)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoClassDefFoundError:
org/apache/commons/io/output/DeferredFileOutputStream
org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:179)
org.apache.commons.fileupload.FileUploadBase.createItem(FileUploadBase.java:500)
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367)
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:116)
lectures.PageAdd.doGet(PageAdd.java:67)
lectures.PageAdd.doPost(PageAdd.java:121)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
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.
A oto fragment kodu który jest umieszczony w metodzie doPost:
This is the code what I have in method doPost:
boolean isMultipart =
FileUpload.isMultipartContent(request);
DiskFileItemFactory factory = new
DiskFileItemFactory();
// Configure the factory here, if desired.
ServletFileUpload upload = new
ServletFileUpload(factory);
// Configure the uploader here, if desired.
List items = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
//processFormField(item);
} else {
//processUploadedFile(item);
}
}
It`s take from Jakarta. (example)
And one, how can I read value varaible which is sending from form?
Great Thanks!