2008-10-06 129 views
4

我希望能夠跟蹤由我的glassfish服務器提供的完整下載。我無法使用servlet生命週期偵聽器找到100%正確的解決方案。 有沒有人有更好的主意?從glassfish跟蹤完成的下載

+0

跟蹤這個問題 2009-10-06 11:54:40

回答

1

IOException上投放try-catch,同時提供文件下載。如果它被拋出,則提供文件下載失敗。

E.g.在自定義文件的servlet:

try { 
    response.getOutputStream().write(...); 

    // Success! 
} catch (IOException e) { 
    // Fail! 

    throw e; 
} 

或者其中在適當的URL的模式匹配文件下載映射Servlet過濾器:

try { 
    chain.doFilter(request, response); 

    // Success! 
} catch (IOException e) { 
    // Fail! 

    throw e; 
}