I am using struts action class to download a file .
  
  
  Here is the action class
  
      public ActionForward execute(ActionMapping aActionMapping, ActionForm 
aActionForm,
               HttpServletRequest aHttpServletRequest, HttpServletResponse  
aHttpServletResponse)
              throws Exception {
  
          aHttpServletResponse.setContentType("application/octet-stream");
          aHttpServletResponse.setHeader("pragma", "no-cache");
          aHttpServletResponse.setHeader("Cache-Control","cache");
          aHttpServletResponse.setHeader("Cache-Control","must-revalidate");    
          
          Integer aSysAttachId = new 
Integer(aHttpServletRequest.getParameter(IWeb.SYS_ATTACH_ID));
           aHttpServletResponse.setHeader("Content-Disposition", "attachment;  
filename=\"" +aHttpServletRequest.getParameter(IWeb.FILE_NAME)+ "\"");
           
download(aApplicationInfoDelegate.getApplicationAttachemntFile(aSysAttachId),aHttpServletResponse);
          return null;
      }
  
      private void download(byte[] byteArray, HttpServletResponse 
httpServletResponse)
              throws IOException, SQLException {
          try {
               BufferedOutputStream aBufferedOutputStream =new  
BufferedOutputStream(httpServletResponse.getOutputStream());
              aBufferedOutputStream.write(byteArray,0,byteArray.length);
              aBufferedOutputStream.close();
          } catch (Exception e) {
              throw new IllegalArgumentException(e.getMessage());
          }
      }
  
  My problem is  with all ".doc "files and some  ".pdf" files  .When  user 
clicks on the link , the browser opens a dialog box  with the option to save or 
open the file   .Suppose he has  choosen a ".doc"  file  to open , the browser 
opens micorsoft  word with an error message 
  
  Word experienced an error tying open the file.
  Try these suggestions.
  * Chaeck the file permissions for the document or drive.
  * Make sure there is sufficient free memory and disk space
  * Open the file with the text Recovery converter.
  
  
  I also had other files  like .xls and lot of .pdf and there is no problem 
with these files  but with all .doc files.
  Can Somebody guide with this issue.
  Thanks & Regards
  
  
   

                
---------------------------------
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, 
whatever.

Reply via email to