1 22 package org.jboss.web.tomcat.filters; 23 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.Enumeration ; 27 import javax.servlet.Filter ; 28 import javax.servlet.FilterChain ; 29 import javax.servlet.FilterConfig ; 30 import javax.servlet.ServletException ; 31 import javax.servlet.ServletRequest ; 32 import javax.servlet.ServletResponse ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.jboss.logging.Logger; 36 37 63 public class ReplyHeaderFilter implements Filter ![JavaDoc](../../../../../../cmn/javadoc.gif) 64 { 65 static Logger log = Logger.getLogger(ReplyHeaderFilter.class); 66 private String [][] replyHeaders = {{}}; 67 68 public void init(FilterConfig config) 69 { 70 Enumeration names = config.getInitParameterNames(); 71 ArrayList tmp = new ArrayList (); 72 while( names.hasMoreElements() ) 73 { 74 String name = (String ) names.nextElement(); 75 String value = config.getInitParameter(name); 76 log.debug("Adding header name: "+name+"='"+value+"'"); 77 String [] pair = {name, value}; 78 tmp.add(pair); 79 } 80 replyHeaders = new String [tmp.size()][2]; 81 tmp.toArray(replyHeaders); 82 } 83 84 public void doFilter(ServletRequest request, ServletResponse response, 85 FilterChain chain) 86 throws IOException , ServletException ![JavaDoc](../../../../../../cmn/javadoc.gif) 87 { 88 HttpServletResponse httpResponse = (HttpServletResponse ) response; 90 for(int n = 0; n < replyHeaders.length; n ++) 91 { 92 String name = replyHeaders[n][0]; 93 String value = replyHeaders[n][1]; 94 httpResponse.addHeader(name, value); 95 } 96 chain.doFilter(request, response); 97 } 98 99 public void destroy() 100 { 101 } 102 } 103 | Popular Tags |