You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Laurens Pit <la...@moonshake.com> on 2000/11/13 20:41:20 UTC

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


Re: downloading Word doc

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Laurens Pit wrote:

> Can someone get this to the developers? Thanks.
>

The most likely scenario is that JRun has a predefined MIME mapping that tells
it to download Word documents as "application/ms-word", and Tomcat doesn't.  To
change this, add an appropriate <mime-mapping> entry in
$TOMCAT_HOME/conf/web.xml (for Tomcat 3.1).  For 3.2, there is unfortunately no
easy way to adjust the default MIME mappings.

Craig McClanahan



Re: downloading Word doc

Posted by Laurens Pit <la...@moonshake.com>.
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
>
>


Re: downloading Word doc

Posted by Laurens Pit <la...@moonshake.com>.
It could be that, however I do notice:

1. When I check with Network Monitor to see the actual bytes that are
received over the internet it shows that the Word document is send
completely. Also, the server reports that it has send the document (the
number of bytes send are equal to the size of the file). So it's not a login
page that is send, the actual file is really send.

2. Point 1 does seem to make a likely that this is a Frontpage
extensions/Office SP1 bug. Should the client solve that, or is possible that
the server could send the stuff in such a way that the bug is avoided? The
reason I ask this is because I don't have the problem with another website.
Another reason why I think it could be solved on the serverside is because
the moment I kill tomcat suddenly the client does show the Word document.


Greets,
Laurens

> Is it just word, or excel, powerpoint, etc too?  Could this be the
Frontpage
> extentions/Office SP1a bug rearing it's ugly head?  This bug causes issues
> when Word tries to download the file, but it doesn't share the same
browser
> cookies/sessions and so it gets sent to a login page or something else
> instead of the file it wants.
>
>
>
> -----Original Message-----
> From: Laurens Pit [mailto:laurens@moonshake.com]
> Sent: Monday, November 13, 2000 02:41 PM
> 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
>
>
>


SSL support

Posted by Christian Pich <cp...@menerva.com>.
I am wondering if there is any SSL support in Tomcat 3.1.
If yes how do I do it?

Christian

Re: jsp not refreshing?

Posted by David Knaack <dk...@rdtech.com>.
From: "Peter Choe" <ch...@mindspring.com>
> i am working on a jsp to list some mail.  when i change the jsp and view
> it in a web browser, for some reason the changes in the html tags
> doesn't show.  is there something in tomcat that causing some type of
> caching of the old jsp files somewhere?

If you are 'include'ing the changed JSP files from another file
you might try 'touch'ing the base file.  I've noticed problems
with IE not actually reloading a page if the requested file
hasn't changed (even if its dynamicly generated JSP contents have).

DK


jsp not refreshing?

Posted by Peter Choe <ch...@mindspring.com>.
i am using tomcat 3.2 on a freebsd machine.

i am working on a jsp to list some mail.  when i change the jsp and view
it in a web browser, for some reason the changes in the html tags
doesn't show.  is there something in tomcat that causing some type of
caching of the old jsp files somewhere?

peter choe

Re: downloading Word doc

Posted by Juan Ramirez <ju...@gluons.com>.
Just a guess, but try setting the content type to application/msword
instead of application/x-www-form-urlencoded.

Juan

CPC Livelink Admin wrote:
> 
> Is it just word, or excel, powerpoint, etc too?  Could this be the Frontpage
> extentions/Office SP1a bug rearing it's ugly head?  This bug causes issues
> when Word tries to download the file, but it doesn't share the same browser
> cookies/sessions and so it gets sent to a login page or something else
> instead of the file it wants.
> 
> -----Original Message-----
> From: Laurens Pit [mailto:laurens@moonshake.com]
> Sent: Monday, November 13, 2000 02:41 PM
> 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

RE: downloading Word doc

Posted by CPC Livelink Admin <cp...@fitzpatrick.cc>.
Is it just word, or excel, powerpoint, etc too?  Could this be the Frontpage
extentions/Office SP1a bug rearing it's ugly head?  This bug causes issues
when Word tries to download the file, but it doesn't share the same browser
cookies/sessions and so it gets sent to a login page or something else
instead of the file it wants.



-----Original Message-----
From: Laurens Pit [mailto:laurens@moonshake.com]
Sent: Monday, November 13, 2000 02:41 PM
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