Hi Roman,
Hmm. Sounds like a weird one. I've used MultipartParser with Apache / JServ
successfully.
First, make sure you are using the latest version of MultipartParser from
Jason's site (of course).
Then, try using the lower level MultipartParser class that comes with the
package and turning off and on the "tuning" options in the constructor to
see if they are having any effect. Maybe the code that was added for
buffering is affecting this.
Probably Jason will see your request, he may have some more ideas.
Let us know how you go.
Cheers
Geoff
----- Original Message -----
From: "Roman Zvyaguintsev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 2:03 PM
Subject: incorrect fule upload
> Hi gurus !
>
> I use example servlet for file upload from o'reilly samples
> (com.oreilly.servlet package). In my workstation on JSDK2.0 that's all ok.
> My gif file is uploaded correctly but on Apache(1.3.19)+JServ 2.1
(JSDK2.0)
> I see following. All 00hex bytes are replaced by 20hex and my gif is
> corrupted !
> Please tell me what do I wrong ?
>
> import java.io.*;
> import java.util.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> import com.oreilly.servlet.MultipartRequest;
>
>
> public class MUpload extends HttpServlet {
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> try {
> // Blindly take it on faith this is a multipart/form-data request
>
> // Construct a MultipartRequest to help read the information.
> // Pass in the request, a directory to save files to, and the
> // maximum POST size we should attempt to handle.
> // Here we (rudely) write to the server root and impose 5 Meg limit.
> MultipartRequest multi =
> new MultipartRequest(req,
> "/apache/htdocs/lab.e-comm.ru/download/DSMS/", 5 * 1024 * 1024);
>
> out.println("<HTML>");
> out.println("<HEAD><TITLE>UploadTest</TITLE></HEAD>");
> out.println("<BODY>");
> out.println("<H1>UploadTest</H1>");
>
> // Print the parameters we received
> out.println("<H3>Params:</H3>");
> out.println("<PRE>");
> Enumeration params = multi.getParameterNames();
> while (params.hasMoreElements()) {
> String name = (String)params.nextElement();
> String value = multi.getParameter(name);
> out.println(name + " = " + value);
> }
> out.println("</PRE>");
>
> // Show which files we received
> out.println("<H3>Files:</H3>");
> out.println("<PRE>");
> 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("length: " + f.length());
> }
> out.println();
> }
> out.println("</PRE>");
> }
> catch (Exception e) {
> out.println("<PRE>");
> e.printStackTrace(out);
> out.println("</PRE>");
> }
> out.println("</BODY></HTML>");
> }
> }
>
> Best regards,
> Roman Zvyaguintsev
> mailto:[EMAIL PROTECTED]
>
>
___________________________________________________________________________
> 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
>
___________________________________________________________________________
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