Upload started ...Server error HTTP/1.1 500 Internal Server
Posted: Thu May 13, 2010 10:46 pm
Uploading : BioAGENT Pre- and Production Tracker.xlsx
(11,211 bytes)
Upload started ...Server error HTTP/1.1 500 Internal Server Error
--------------------------------------------------
I continually get this error.
I am trying to deploy to Tomcat 6 on my machine(localhost).
I am trying to recreate folders/subfolders on server.
I beleive I have correctly modified the code for recreate folders/subfolders.
The url is correct.
Can someone give me suggestions? I am at wits end.
process.jsp
applet_http.js
(11,211 bytes)
Upload started ...Server error HTTP/1.1 500 Internal Server Error
--------------------------------------------------
I continually get this error.
I am trying to deploy to Tomcat 6 on my machine(localhost).
I am trying to recreate folders/subfolders on server.
I beleive I have correctly modified the code for recreate folders/subfolders.
The url is correct.
Can someone give me suggestions? I am at wits end.
process.jsp
Code: Select all
<%@ page language="java" import="jfileupload.jspupload.*,java.util.*,java.io.*"%>
<%@ page errorPage="ExceptionHandler.jsp"%>
<!-- StrutsDemoApp-->
<% String directory = "c:/uploads"; %>
<% String tmpdirectory = "c:/uploads/tmp"; %>
<% boolean createsubfolders = true; %>
<% boolean allowresume = true; %>
<% boolean allowoverwrite = true; %>
<% String encoding = "ISO-8859-1"; %>
<% boolean keepalive = false; %>
<jsp:useBean id="upBean" scope="page" class="jfileupload.jspupload.FileUploadBean">
<jsp:setProperty name="upBean" property="folderstore" value="<%= directory %>" />
<jsp:setProperty name="upBean" property="parsertmpdir" value="<%= tmpdirectory %>" />
<jsp:setProperty name="upBean" property="filesizelimit" value="99999999999"/>
<jsp:setProperty name="upBean" property="overwrite" value="<%= allowoverwrite %>" />
<jsp:setProperty name="upBean" property="dump" value="true" />
</jsp:useBean>
<%
//request.setCharacterEncoding(encoding);
//response.setContentType("text/html; charset="+encoding);
String method = request.getMethod();
// Head processing to support resume and overwrite features.
if (method.equalsIgnoreCase("head"))
{
String filename = request.getHeader("relativefilename");
if (filename == null) filename = request.getHeader("filename");
if (filename != null)
{
if (keepalive == false) response.setHeader("Connection", "close");
String account = request.getHeader("account");
if (account == null) account = "";
else if (!account.startsWith("/")) account = "/" + account;
File fhead = new File(directory + account + "/" + filename);
if (fhead.exists())
{
response.setHeader("size", String.valueOf(fhead.length()));
String checksum = request.getHeader("checksum");
if ((checksum != null) && (checksum.equalsIgnoreCase("crc")))
{
long crc = upBean.computeCRC32(fhead, -1);
if (crc != -1) response.setHeader("checksum", String.valueOf(crc));
}
else if ((checksum != null) && (checksum.equalsIgnoreCase("md5")))
{
String md5 = upBean.hexDump(upBean.computeMD5(fhead, -1)).toLowerCase();
if ((md5 != null) && (!md5.equals(""))) response.setHeader("checksum", md5);
}
}
else response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
}
%>
<html>
<head>
<title>Upload file: JSPScript sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
</head>
<body>
<ul>
<%
if (MultipartFormDataRequest.isMultipartFormData(request))
{
// Parse multipart HTTP POST request.
MultipartFormDataRequest mrequest = null;
try
{
mrequest = new MultipartFormDataRequest(request, null, -1, MultipartFormDataRequest.CFUPARSER, encoding, allowresume);
}
catch (Exception e)
{
// Cancel current upload (e.g. Stop transfer)
// Only if allowresume = false
}
String todo = null;
if (mrequest != null) todo = mrequest.getParameter("todo");
if ((todo != null) && (todo.equalsIgnoreCase("upload")))
{
String account = mrequest.getParameter("account");
if (account == null) account = "";
else if (!account.startsWith("/")) account = "/" + account;
upBean.setFolderstore(directory + account);
Hashtable files = mrequest.getFiles();
//Added by ray
int filesLength = files.size();
if ((files != null) && (!files.isEmpty()))
{
UploadFile file = (UploadFile) files.get("uploadfile");
if (file != null) out.println("<li>Form field: uploadfile" + "<BR> Uploaded file: " + file.getFileName() + " (" + file.getFileSize() + " bytes)" + "<BR> Content Type: " + file.getContentType());
// Folders and subfolders creation support.
String relative = mrequest.getParameter("relativefilename");
System.out.println("relative = "+ relative);
if ((createsubfolders == true) && (relative != null))
{
int inda = relative.length();
int indb = file.getFileName().length();
if (inda > indb)
{
String subfolder = relative.substring(0, (inda - indb) - 1);
subfolder = subfolder.replace('\\', '/').replace('/', java.io.File.separatorChar);
upBean.setFolderstore(directory + account + java.io.File.separator + subfolder);
}
}
if (keepalive == false) response.setHeader("Connection", "close");
// Chunks recomposion support.
String chunkidStr = mrequest.getParameter("chunkid");
String chunkamountStr = mrequest.getParameter("chunkamount");
String chunkbaseStr = mrequest.getParameter("chunkbase");
if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
{
// Always overwrite chunks.
upBean.store(mrequest, "uploadfile");
int chunkid = Integer.parseInt(chunkidStr);
int chunkamount = Integer.parseInt(chunkamountStr);
if (chunkid == chunkamount)
{
// recompose file.
String fname = upBean.getFolderstore() + java.io.File.separator + chunkbaseStr;
File fread = new File(fname);
if (fread.canRead() && (upBean.getOverwrite() == false)) fname = fname + "." + System.currentTimeMillis();
FileOutputStream fout = new FileOutputStream(fname);
byte[] buffer = new byte[4096];
for (int c = 1; c <= chunkamount; c++)
{
File filein = new File(upBean.getFolderstore() + java.io.File.separator + chunkbaseStr + "." + c);
FileInputStream fin = new FileInputStream(filein);
int read = -1;
while ((read = fin.read(buffer)) > 0) fout.write(buffer, 0, read);
fin.close();
filein.delete();
}
fout.close();
}
}
else upBean.store(mrequest, "uploadfile");
upBean.setFolderstore(directory + account);
}
else
{
String emptydirectory = mrequest.getParameter("emptydirectory");
if ((emptydirectory != null) && (!emptydirectory.equals("")))
{
File dir = new File(directory + account + "/" + emptydirectory);
dir.mkdirs();
}
out.println("<li>No uploaded files");
}
}
else out.println("<BR> todo=" + todo);
}
%>
</ul>
<form method="post" action="process.jsp" name="upform" enctype="multipart/form-data">
<br>
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td align="left"><b>Select a file to upload:</b></td>
</tr>
<tr>
<td align="left"><input type="hidden" name="todo" value="upload">
<input type="file" name="uploadfile" size="50"></td>
</tr>
<tr>
<td align="left"><input type="submit" name="Submit" value="Upload"> <input type="reset" name="Reset" value="Cancel"></td>
</tr>
</table>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="-1" face="Courier New, Courier, mono"><a href="http://www.jfileupload.com" target="_blank">JFileUpload</a></font></p>
</form>
</body>
</html>
Code: Select all
<!--
var _info = navigator.userAgent;
var _ns = false;
var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
if (_info.indexOf("Opera") > 0) _ie = false;
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
if (_ie == true) {
document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="550" HEIGHT="250" NAME="fileupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">');
}
else if (_ns == true && _ns6 == false) {
// BEGIN: Update parameters below for NETSCAPE 3.x and 4.x support.
document.write('<EMBED ');
document.write('type="application/x-java-applet;version=1.4" ');
document.write('CODE="jfileupload.upload.client.MApplet.class" ');
document.write('JAVA_CODEBASE="./" ');
document.write('ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" ');
document.write('NAME="fileupload" ');
document.write('WIDTH="250" ');
document.write('HEIGHT="250" ');
//document.write('url="http://192.168.5.24:8080/JFileUploadHTTP/process.jsp" ');
// document.write('url="http://12.144.92.205:8080/JFileUploadHTTP/process.jsp" ');
document.write('url="http://localhost:8087/StrutsDemoApp/process.jsp" ');
document.write('paramfile="uploadfile" ');
document.write('param1="todo" ');
document.write('value1="upload" ');
document.write('folderdepth="-1" ');
document.write('param2="relativefilename" ');
document.write('value2="true" ');
document.write('mode="http" ');
document.write('scriptable=true ');
document.write('resources="i18n"');
document.write('hidebar="false"');
document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
// END
}
else {
document.writeln('<APPLET CODE="jfileupload.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH="250" HEIGHT="250" NAME="fileupload">');
}
// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
//document.writeln('<PARAM NAME="url" VALUE="http://192.168.5.24:8080/JFileUploadHTTP/process.jsp">');
//document.writeln('<PARAM NAME="url" VALUE="http://12.144.92.205:8080/JFileUploadHTTP/process.jsp">');
//document.writeln('<PARAM NAME="url" VALUE="http://12.144.92.205:8080/StrutsDemoApp/process.jsp">');
document.writeln('<PARAM NAME="url" VALUE="http://localhost:8087/StrutsDemoApp/process.jsp">');
document.writeln('<PARAM NAME="paramfile" VALUE="uploadfile">');
document.writeln('<PARAM NAME="param1" VALUE="todo">');
document.writeln('<PARAM NAME="value1" VALUE="upload">');
document.writeln('<PARAM NAME="folderdepth" VALUE="-1">');
document.writeln('<PARAM NAME="param2" VALUE="relativefilename">');
document.writeln('<PARAM NAME="value2" VALUE="true">');
document.writeln('<PARAM NAME="mode" VALUE="http">');
document.writeln('<PARAM NAME="resources" VALUE="i18n">');
document.writeln('<PARAM NAME="hidebar" VALUE="false">');
// END
if (_ie == true) {
document.writeln('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
document.writeln('</NOEMBED></EMBED>');
}
else {
document.writeln('</APPLET>');
}
//-->