tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Freeman <Russell.Free...@sagemaker.com>
Subject RE: downloading Word doc
Date Thu, 16 Nov 2000 15:51:14 GMT
We've recently had a similar problem with Word. It seems that when a .doc
link is clicked, Word is handed the request to download. It establishes its
own server connection and then proceeds to fire the server with numerous
HTTP requests. On examination, it seems these are Word probing for Frontpage
web extensions. If you have implemented your own HTTP server it is possible
that you are not sending back the right responses? In most cases you need to
return 404 responses to Word to indicate that you don't have the requested
resources. Our problem was that our HTTP server only expected GET requests,
whereas Word was POSTing us info!

Hope that helps,
Russ

-----Original Message-----
From: Laurens Pit [mailto:laurens@moonshake.com]
Sent: 13 November 2000 19:41
To: tomcat-user@jakarta.apache.org
Subject: downloading Word doc


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