tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "codedummy" <codedu...@hotmail.com>
Subject Re: please try: java renameTo problem apache / tomcat
Date Wed, 09 Apr 2003 12:28:58 GMT
Hello again,

Has somone already tried this? Seems to be a general Bug. I achivied it now
with different file upload servlets and different jvm. Maybe i've to post a
bug report to sun or apache or tomcat or all of them.

Greetings and Thanks
Peter
----- Original Message -----
From: "Peter H." <codedummy@hotmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, April 08, 2003 4:02 PM
Subject: please try: java renameTo problem apache / tomcat


> Hello,
>
> Please try the following...takes only about 5 minutes
>
> Steps to achieve the same general Upload - misbehaviour of Java Servlets
> Tomcat and Apache:
>
> 1) Download http://www.servlets.com/cos/index.html
> or some othe FileUpload enabled ServetRequest.
>
> 2) Put the attached servlet to your server.
> Change "/export/wwwdoc/" to a apache accessible folder...
> Change "/tmp" to some temporary directory
> Maybe change test.jpg to another name. (e.g. "/export/wwwdoc/test.jpg")
>
> 3) put a proper data in your server.xml or web-inf/web.xml to access the
> servlet (servlet is attached)
>
> 4) request the servlet. (eg http://127.0.0.1/fileservlet)
> You will see a Upload field. Choose a jpg from your harddisk and upload
it.
> (now be a little bit quick...)
>
> 5) request the jpg with apache (eg. http://127.0.0.1/test.jpg)
>
> 6) upload the same or a different image with the fileservlet.
> (see step 4)
>
> 7) after the first or second try you will probably get the same Error as I
> and the servlet prints "renameTo failed"
>
> 8) Any Ideas? Please help....
>
> If you skip step 5 you can overwrite as often as you like...
> if apache / java has enough time between step 4 and 5 it will also
> succeed....
>
> This behaviour can be achieved under linux (debian, suse), windows
200x,...
>
>
> Greetings and Thanks
> Peter
>
>
>
>
>
> FileServlet.java:
> ####################################################
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.util.*;
>
> public final class FileServlet
>     extends HttpServlet {
>
>     static public final String TARGET =
>         "/export/wwwdoc/test.jpg";
>
>     public void service(HttpServletRequest req, HttpServletResponse resp)
> throws
>         IOException {
>
>         com.oreilly.servlet.MultipartRequest request = new
> com.oreilly.servlet.MultipartRequest(req, "/tmp");
>
>         File source = null;
>         if(request.getFile("file") != null) {
>             source = request.getFile("file");
>         }
>         PrintWriter writer = resp.getWriter();
>         writer.write("<HTML>");
>         writer.write("<BODY>");
>         writer.write("<FORM NAME=\"main\"
> ACTION=\"http://127.0.0.1/fileservlet\" METHOD=\"post\"
> ENCTYPE=\"multipart/form-data\">");
>         writer.write("<INPUT TYPE=\"file\" NAME=\"file\"/>");
>         writer.write("<INPUT TYPE=\"submit\" VALUE=\"upload\"/>");
>         writer.write("<hr>");
>         if(source != null) {
>             File target = new File(TARGET);
>             if(target.exists()) {
>                 writer.write("Target file exists<br>");
>                 if(!target.delete()) {
>                     writer.write("Target file delete failed:" + target +
> "<br>");
>                     return;
>                 }
>             }
>             if(source.renameTo(target)) {
>                 writer.write("rename succeeded<br>");
>             }
>             else {
>                 writer.write("rename failed<br>");
>             }
>         }
>         writer.write("</FORM>");
>         writer.write("</BODY>");
>         writer.write("</HTML>");
>     }
> }
> EOF##############################################################
>
>
>
>
>
> _________________________________________________________________
> MSN Hotmail - Absolut kostenfrei! Der weltweit größte E-Mail-Anbieter im
> Netz:  http://www.msn.de/hotmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message