hi,
I am having difficulties in downloading files through the slide interface I developed. It works for txt file bu t does not work for doc or pdf files. It transfer the doc files corrupted.




My function that I am calling from JSP page is

public void getResource(String src,HttpServletResponse response,
                          JspWriter out) {

try {

byte[] buf = new byte[4096];
int size;
String oldpath = webdavResource.getPath();
webdavResource.setPath(src);
if(webdavResource.exists()) {
InputStream is = webdavResource.getMethodData();
if(is != null) {
response.setContentType(webdavResource.getGetContentType());
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment; filename=\""+ webdavResource.getDisplayName() +"\"");
System.err.println("file name is ----->"+webdavResource.getDisplayName());
System.err.println("file name is ----->"+webdavResource.getGetContentType());


                  int i;
                  while((i = is.read()) != -1) {
                      out.write(i);
                  }

                  /*while((size=is.read(buf))>0) {
                      os.write(buf, 0, size);
                  } */

                  //os.close();
                  out.close();
                  is.close();
              } else {
                  webdavResource.getStatusMessage();
              }
          }
          webdavResource.setPath(oldpath);
      } catch(HttpException we) {
          System.err.println("Warning: " + we.getMessage());
      }
       catch(IOException e) {
          System.err.println("Error: Check! " + e.getMessage());
      }
  }




and I am calling this from JSP file by a link


<a href="dirlist.jsp?<%=download%>path=<%= r.getPath() %>">

get path gives the path of the file


and the function is called like this



else if(command.equals("download")) { jspsession.getResource(newPath, response, out); return;

}



I spent so much time to fix this but I could not.
If anyone give me a hand in this I would be very glad and thankfull.
thanks



Cevat Ikibas
Office: 812-8560753
Home  : 812-3310332

_________________________________________________________________
Need more e-mail storage? Get 10MB with Hotmail Extra Storage. http://join.msn.com/?PAGE=features/es



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



Reply via email to