filter 파일 업로드 -egov
package kr.co.egov.upb.web;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.web.filter.OncePerRequestFilter;
import kr.co.egov.upb.service.ProgressCapableMultipartResolver;
import kr.co.egov.upb.service.ProgressDescriptor;
public class UploadProgressFilter extends OncePerRequestFilter{
Logger log = Logger.getLogger(this.getClass());
private final String PROGRESS_TAIL = ".progress";
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String requestUri = request.getRequestURI();
String originalUrl = requestUri.substring(0, requestUri.length()
- PROGRESS_TAIL.length());
String attributeName = ProgressCapableMultipartResolver.PROGRESS_PREFIX + originalUrl;
Object progress = request.getSession().getAttribute(attributeName);
if(progress != null){
ProgressDescriptor descriptor = (ProgressDescriptor)progress;
log.debug("[pBytesRead=" + descriptor.getBytesRead() + ",
pContentLength=" + descriptor.getBytesTotal() + "]");
response.getOutputStream().write(descriptor.toString().getBytes() );
response.getOutputStream().flush();
response.getOutputStream().close();
}
}
}
'JAVA' 카테고리의 다른 글
[JAVA]Filter를 이용한 multipart/form-data 처리 및 파일 업로드 처리 (0) | 2017.11.23 |
---|---|
[JAVA]filter 필터 (0) | 2017.11.23 |
[JAVA]Filter 응용 (0) | 2017.11.21 |
[JAVA]filter 사용자관리 (0) | 2017.11.16 |
[JAVA]Filter XSS Cross-Site Scripting (XSS) 필터 (0) | 2017.11.16 |