----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

All-
I am having a bit of trouble uploading files using Apache 1.3.9 winnt +
JServ 1.0.  I have read through as many of the FAQ as I could.  I build a
really small file upload servlet using the multipart support (as suggested
in this discussion) from http://www.servlets.com

I am running on NT, however our production server is a Solaris 7 box, and
has the same problem.  Most files can be uploaded with no difficulty, so I
know that it is not an issue of inappropriately querying for the HTTP
headers.  Other files (most reliably *.eps files) cause the following
errors:

(from jserv.log)
[19/10/1999 20:07:44:582 MDT] java.lang.ArrayIndexOutOfBoundsException
 at javax.servlet.ServletInputStream.readLine(ServletInputStream.java,
Compiled Code)
 at
com.oreilly.servlet.MultipartInputStreamHandler.readLine(MultipartRequest.ja
va, Compiled Code)
 at
com.oreilly.servlet.MultipartRequest.readAndSaveFile(MultipartRequest.java,
Compiled Code)
 at
com.oreilly.servlet.MultipartRequest.readNextPart(MultipartRequest.java:352)
 at com.oreilly.servlet.MultipartRequest.readRequest(MultipartRequest.java,
Compiled Code)
 at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:140)
 at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:96)
 at FileUpload.doPost(FileUpload.java, Compiled Code)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
 at org.apache.jserv.JServConnection.processRequest(JServConnection.java)
 at org.apache.jserv.JServConnection.run(JServConnection.java)
 at java.lang.Thread.run(Thread.java:479)

(from error.log)
[Tue Oct 19 20:07:45 1999] [error] [client 127.0.0.1] Premature end of
script headers: /servlets/FileUpload

I have a file that reliably causes the problem, if anyone is interested.  I
didn't want to attach it, because this is already a really large post.  Any
help on this would be greatly appreciated.

The test servlet is as follows:

public class FileUpload extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{

  res.setContentType("text/html");
  PrintWriter out = new PrintWriter (res.getOutputStream());
  MultipartRequest multi = new MultipartRequest(req, ".");
  out.println("<html>");
  out.println("<head><title>FileUpload</title></head>");
  out.println("<body>");

  out.println("Params:");
  Enumeration params = multi.getParameterNames();
  while (params.hasMoreElements())
  {
       String name = (String)params.nextElement();
       String value = multi.getParameter(name);
       out.println(name + " = " + value);
  }
  out.println();
  out.println("Files:");
  Enumeration files = multi.getFileNames();
  while (files.hasMoreElements())
  {
       String name = (String)files.nextElement();
       String filename = multi.getFilesystemName(name);
       String type = multi.getContentType(name);
       File f = multi.getFile(name);
       out.println("name: " + name);
       out.println("filename: " + filename);
       out.println("type: " + type);
       if (f != null)
       {
            out.println("f.toString(): " + f.toString());
            out.println("f.getName(): " + f.getName());
            out.println("f.exists(): " + f.exists());
            out.println("f.length(): " + f.length());
            out.println();
       }
    }
}

The test page that is used to select the file is:

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
FileUpload
</TITLE>
</HEAD>
<BODY>

<FORM  action=http://localhost:8080/servlet/FileUpload
enctype="multipart/form-data" method="POST">
<BR><BR> press Submit to launch servlet FileUpload
<BR><BR><input type=file name=thefile><br><input type=submit
value="Submit"><input type=reset value="Reset"></form>
</BODY>
</HTML>

Sorry for the long post.  I don't know what else to try.  My site is already
in production.

-Justin




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to