Announcement Announcement Module
Collapse
No announcement yet.
SWF, JSF, WAS, download file, Out Of Memory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF, JSF, WAS, download file, Out Of Memory

    I am using WAS 6.1 App Server, Spring 3.0.3, SWF 2.1.1, JSF 1.2 and facelets. I hava a big problem with download files (pdf or zip/rar). When I download large files, I receive Out Of Memory error (max heap size: 1024MB). I used JProfiler tool and there was more than 700MB allocated to byte[].
    My code:

    SWF:
    Code:
    <view-state id="test" view="test.xhtml">
         <transition on="download" to="download" />
    </view-state>
      	
    <action-state id="download">
        <evaluate expression="downloadService.downloadFile(listFiles.selectedRow.file.path)" />
        <transition on="ok" to="test" />
        <transition on="fileNotFound" to="test">
      	<set name="flashScope.message" value="resourceBundle.noFiles" />
        </transition>
    </action-state>

    Java code:

    Code:
    public String downloadFile(String path){
    try{
         ExternalContext externalContext = ExternalContextHolder.getExternalContext();
         HttpServletResponse response = (HttpServletResponse) externalContext.getNativeResponse();
         File file = new File(path);
         FileInputStream in = new FileInputStream(file);
         ServletOutputStream out = response.getOutputStream();
         response.setHeader("Content-Disposition","attachment; filename=\"" +      filename +"\" ");
         response.setHeader("Content-Type", "application/octet-stream");   
         response.setHeader("Content-Length", String.valueOf(file.length()));
    
         FileCopyUtils.copy(in, out);
         externalContext.recordResponseComplete();
         return "ok";
    }
    catch(FileNotFoundException fnf){
     return "fileNotFound"
    }
    Any suggestions to resolve this problem?
Working...
X