1 package org.kuali.ole;
2
3
4 import javax.servlet.*;
5 import java.io.IOException;
6
7
8
9
10
11
12
13
14 public class CharsetFilter implements Filter {
15
16 private String encoding;
17
18 public void init(FilterConfig config) throws ServletException {
19 encoding = config.getInitParameter("requestEncoding");
20 if (encoding == null) {
21 encoding = "UTF-8";
22 }
23 }
24
25 public void doFilter(ServletRequest request, ServletResponse response, FilterChain next)
26 throws IOException, ServletException {
27 if (null == request.getCharacterEncoding()) {
28 request.setCharacterEncoding(encoding);
29 }
30 response.setContentType("text/html; charset=UTF-8");
31 response.setCharacterEncoding("UTF-8");
32 next.doFilter(request, response);
33 }
34
35 public void destroy() {
36 }
37
38 }
39