1 25 package org.snipsnap.net.filter; 26 27 import org.radeox.util.logging.Logger; 28 29 import javax.servlet.*; 30 import javax.servlet.http.HttpServletRequest ; 31 import java.io.IOException ; 32 33 40 public class MultipartFilter implements Filter { 41 42 public void init(FilterConfig config) throws ServletException { 43 } 44 45 public void destroy() { 46 } 47 48 public void doFilter(ServletRequest request, ServletResponse response, 49 FilterChain chain) throws IOException , ServletException { 50 HttpServletRequest req = (HttpServletRequest ) request; 51 String type = req.getHeader("Content-Type"); 52 53 if (type == null || !type.startsWith("multipart/form-data")) { 55 chain.doFilter(req, response); 56 } else { 57 try { 58 chain.doFilter(new MultipartWrapper(req, "UTF-8"), response); 59 } catch (IllegalArgumentException e) { 60 Logger.warn("MultipartFilter: "+e.getMessage()); 61 } 62 } 63 } 64 } | Popular Tags |