Hi,
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);
                return;
        }

response.setContentType("application/octet-stream");

response.setHeader("Content-Disposition","filename=" + 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 = in.read()) != -1)
     {
       out.write(b);
     }
     in.close();
     out.close();

}

_________________________________________________________________
High-speed users�be more efficient online with the new MSN Premium Internet Software. http://join.msn.com/?pgmarket=en-us&page=byoa/prem&ST=1



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to