1 59 60 61 package com.sslexplorer.core; 62 63 64 import java.io.IOException ; 65 66 import javax.servlet.Filter ; 67 import javax.servlet.FilterChain ; 68 import javax.servlet.FilterConfig ; 69 import javax.servlet.ServletException ; 70 import javax.servlet.ServletRequest ; 71 import javax.servlet.ServletResponse ; 72 73 74 79 91 92 public class SetCharacterEncodingFilter implements Filter { 93 94 95 97 98 102 protected String encoding = null; 103 104 105 109 protected FilterConfig filterConfig = null; 110 111 112 114 115 118 public void destroy() { 119 120 this.encoding = null; 121 this.filterConfig = null; 122 123 } 124 125 126 137 public void doFilter(ServletRequest request, ServletResponse response, 138 FilterChain chain) 139 throws IOException , ServletException { 140 141 String encoding = selectEncoding(request); 143 if (encoding != null) 144 request.setCharacterEncoding(encoding); 145 146 chain.doFilter(request, response); 148 149 } 150 151 152 157 public void init(FilterConfig filterConfig) throws ServletException { 158 159 this.filterConfig = filterConfig; 160 this.encoding = filterConfig.getInitParameter("encoding"); 161 162 } 163 164 165 167 168 180 protected String selectEncoding(ServletRequest request) { 181 182 return (this.encoding); 183 184 } 185 186 187 } 188 189 | Popular Tags |