KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > util > SetCharacterEncodingFilter


1 /**
2  * $RCSfile: SetCharacterEncodingFilter.java,v $
3  * $Revision: 1.1 $
4  * $Date: 2004/12/27 02:53:31 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.util;
13
14 import javax.servlet.*;
15 import java.io.IOException JavaDoc;
16
17
18 /**
19  * Sets the character encoding to UTF-8.
20  *
21  * @author Matt Tucker
22  */

23 public class SetCharacterEncodingFilter implements Filter {
24
25     public void init(FilterConfig filterConfig) throws ServletException {
26
27     }
28
29     public void destroy() {
30         
31     }
32
33     /**
34      * Sets the character encoding to be used for any content passing out of this filter.
35      */

36     public void doFilter(ServletRequest request, ServletResponse response,
37             FilterChain chain) throws IOException JavaDoc, ServletException
38     {
39         request.setCharacterEncoding("UTF-8");
40         response.setContentType("text/html; charset=" + "UTF-8");
41         chain.doFilter(request, response);
42     }
43 }
44
Popular Tags