tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurens Pit" <laur...@moonshake.com>
Subject Re: downloading Word doc
Date Tue, 14 Nov 2000 10:41:07 GMT
Can someone get this to the developers? Thanks.

After some more research I do believe there's a bug in Tomcat somewhere. I
hosted my simple servlet in Allaire's JRun on Windows 2000, and it works
fine. Also when I host the servlet in Netscape's IPlanet it works fine. See
the code of the servlet below to test this.

Versions tested: Tomcat 3.1 final, Tomcat 3.2 beta 7
Platform client: Windows 2000.
Platform server: tested on Windows 2000, Linux RedHat v6.2 and Sun Solaris
8.

java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)



Greets,
Laurens

> Hi,
>
> Whenever I download a file using Tomcat (i.e. it uses
> org.apache.tomcat.servlets.DefaultServlet) it works, except when I try to
> download a Word document. Then the client side seems to get stuck. This is
> reproducable on different client machines using different servers (Linux
and
> Sun). Is anyone else experiencing this problem?
>
> I have also created a very simple Servlet to download a file. Works fine,
> except again for Word documents. Downloading Word documents from e.g.
> www.idrive.com work fine though, so it must be some servers-side thing.
Can
> anyone please help??
>
>
> package com.nervewireless;
>
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public final class FileDownload extends HttpServlet
> {
>     public void doGet(HttpServletRequest req, HttpServletResponse res)
>         throws IOException, ServletException
>     {
>         String path = "C:\\TEMP\\" + req.getPathInfo().substring(1);
>         System.out.println("PATH: " + path);
>
>         File f = new File(path);
>         InputStream  in  = new BufferedInputStream(new
FileInputStream(f));
>
>         res.setContentType("application/x-www-form-urlencoded");
>         res.setContentLength((int) f.length());
>         res.setHeader("Content-disposition","attachement; filename=" +
> f.getName());
>         OutputStream out = res.getOutputStream();
>
>         int  sentsize = 0;
>         int  readlen;
>         byte buffer[] = new byte[256];
>
>         while ((readlen = in.read(buffer)) != -1 ) {
>           out.write(buffer, 0, readlen);
>           sentsize += readlen;
>         }
>
>         // Success ! Close streams.
>         out.flush();
>         out.close();
>         in.close();
>
>   System.out.println("DONE!");
>  }
> }
>
>
>
>
> Greets,
> Laurens
>
>


Mime
View raw message