tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jake Alley" <>
Subject Differences betwen Tomcat 5 and 4 writing to output stream?
Date Wed, 28 Jan 2004 20:12:38 GMT
  I just upgraded to TC 5 from TC 4 running on RH linux 9.  I had a servlet 
that acted as a downloader for file requests to a restriced directory.  It 
worked very well in 4, but now it doesn't work in 5.  In 5 it adds a small 
number of bytes in the output stream.  It doesn't have to do with adding a 
CR every time it sees an LF or anything like that.  It adds about 10 bytes 
at the beginning and then nothing else.  Weird.

Here's my code.  I did have some other problems with using the wrong 
servlet-api version to compile, but those are fixed I think.  Thanks.

public void doGet(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException

	int i = request.getRequestURI().lastIndexOf("/");
	String fileName = request.getRequestURI().substring(i+1);
	Downloader dl = new Downloader();
	if (dl.checkContactInfo(request, fileName) == false)
		response.sendRedirect("/sysforms/dlcontact.jsp?filename=" + fileName);


                response.setHeader("Content-Disposition","filename=" + 

	String path = manager.getBaseDir() + "/"  + request.getRequestURI();
	File file = new File(path);

	response.setContentLength((int) file.length());

    PrintWriter out = new PrintWriter (response.getOutputStream());

      int b;
      BufferedInputStream in = new BufferedInputStream (
        new FileInputStream(file));
      while ((b = != -1)


High-speed usersóbe more efficient online with the new MSN Premium Internet 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message