Of course, the bug may just be in my own head. But I have
pounded on this for a few hours now, and (at the very least)
I can now reproduce the problem easily: it takes but one
line added to Jason's example program, UploadTest.java.
(Before going any further I must add my voice to the chorus:
Jason's book is incredibly useful to me in my work, and this
message is -not- meant as criticism or callow sniping.)
The background: I have a servlet of some 1000 lines to
do (among other things) a file upload. I use a login with
password to protect against unwanted uploads, and I use
an HttpSession to track (and to expire) legitimate uploads.
Every time the servlet gets hit, I check to see if a valid
login is still in effect.
I do this checking in a little method "loginRequired ()" which
checks some features (a parameter or two, the HttpSession) of
the HttpServletRequest passed into both my doPost and doGet.
And there's the rub: apparently any enquires made of the
HttpServletRequest do serious harm to that request in the
eyes of the MultipartRequest class.
You can reproduce this (Jason?) by adding a single line to
UploadRequest.java;
--> String opt = req.getParameter ("opt");
MultipartRequest multi =
new MultipartRequest(req, ".", 5 * 1024 * 1024); // line 26
The ensuing exception trace:
java.io.IOException: Corrupt form data: premature ending
at com.oreilly.servlet.MultipartRequest.readRequest(MultipartRequest.java:275)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:140)
at UploadTest.doPost(UploadTest.java:26)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.run(JServConnection.java:359)
at java.lang.Thread.run(Thread.java)
So it looks like simply calling "getParameter" on the HttpServletRequest
is enough to ruin that request, making it corrupt in the eyes of
the MultipartRequest.readRequest method.
I am running Apache 1.34, jserv 10b3, jdk 1.1.7, all on Solaris 2.6,
with the latetest com.oreilly.servlet.MultipartRequest from cos.jar,
recently downloaded, and dated January 15th 1999.
Can anyone help?
Thanks.
- Paul Shannon
University of Washington Medical Center
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html