Guys,
Im using the classes from jakarta to do an upload of a document onto my webserver.
I get the following error
500 org/apache/commons/fileupload/FileUploadBase
org/apache/commons/fileupload/FileUploadBase
Any idea what it can be? Im sure my code is right.
The code for the form is:
<form method="POST" action="./servlet/REJfiles.UploadServlet" enctype="multipart/form-data">
<p><input type="text" name="paperTitle" size="50"></p>
<p><input type="text" name="coAuthors" size="50"></p>
<p><input type="file" name="file" size="50"></p>
<p><font face="Arial">Please make sure you have read the 'instructions
for authors'</font></p>
<input type="submit" value="Submit.." />
<p> </p>
<p> </p>
<p> </p>
</form>
and the servelet code is as follow:
public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("user_id");
String paperID = request.getParameter("paper_id");
String baseDir = this.getServletContext().getRealPath("/");
boolean isMultipart = FileUpload.isMultipartContent(request);
String filePath =
new FileUtil().generateFilePath(
baseDir,
"Paper",
username,
paperID);
if (isMultipart) {
DiskFileUpload upload = new DiskFileUpload();
//Parse the request
try {
//upload.setRepositoryPath(filePath);
// Parse the request
List /* FileItem */
items = upload.parseRequest(request);
//
Iterator iter = items.iterator();
FileItem item = null;
String fileName = "nothing.txt";
try {
while (iter.hasNext()) {
item = (FileItem) iter.next();
fileName = item.getName();
File uploadedFile =
new FileUtil().create(filePath, fileName);
item.write(uploadedFile);
response.sendRedirect("http://www.google.co.uk");
return;
}
} catch (Exception e1) {
System.out.println("Error in writing upload file");
e1.printStackTrace();
}
} catch (FileUploadException e) {
System.out.println("Error FileUploadException!");
e.printStackTrace();
}
} else
response.sendRedirect("http://www.bbc.co.uk/news");
}
Can you see a problem anywhere in the code?
I've routed the sendRedirect to different websites to show me if it works or not, dont pay too much attention to that, im going to change it once im done.
Thanks in advance
Zein