1 15 package org.apache.tapestry.multipart; 16 17 import java.io.IOException ; 18 19 import javax.servlet.ServletException ; 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.http.HttpServletResponse ; 22 23 import org.apache.tapestry.services.ServletRequestServicer; 24 import org.apache.tapestry.services.ServletRequestServicerFilter; 25 26 33 public class MultipartDecoderFilter implements ServletRequestServicerFilter 34 { 35 private MultipartDecoder _decoder; 36 37 public void service(HttpServletRequest request, HttpServletResponse response, 38 ServletRequestServicer servicer) throws IOException , ServletException 39 { 40 String contentType = request.getContentType(); 41 42 46 boolean encoded = contentType != null && contentType.startsWith("multipart/form-data"); 47 48 try 49 { 50 HttpServletRequest newRequest = encoded ? _decoder.decode(request) : request; 51 52 servicer.service(newRequest, response); 53 } 54 finally 55 { 56 if (encoded) 57 _decoder.cleanup(); 58 } 59 } 60 61 public void setDecoder(MultipartDecoder decoder) 62 { 63 _decoder = decoder; 64 } 65 } | Popular Tags |