KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > utils > CharsetFilter


1 /*
2  ************************************************************************************
3  * Copyright (C) 2001-2006 Openbravo S.L.
4  * Licensed under the Apache Software License version 2.0
5  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6  * Unless required by applicable law or agreed to in writing, software distributed
7  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8  * CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations under the License.
10  ************************************************************************************
11 */

12 package org.openbravo.utils;
13
14 import java.io.*;
15 import javax.servlet.*;
16
17 public class CharsetFilter implements Filter {
18   private String JavaDoc encoding;
19
20   public void init(FilterConfig config) throws ServletException {
21     encoding = config.getInitParameter("requestEncoding");
22     if( encoding==null ) encoding="UTF-8";
23   }
24
25   public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException {
26     request.setCharacterEncoding(encoding);
27     next.doFilter(request, response);
28   }
29
30   public void destroy(){}
31 }
32
Popular Tags