source: nutchez-0.1/tomcat/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java @ 66

Last change on this file since 66 was 66, checked in by waue, 15 years ago

NutchEz - an easy way to nutch

File size: 1.9 KB
Line 
1/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements.  See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License.  You may obtain a copy of the License at
8*
9*     http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17
18package compressionFilters;
19
20import java.io.IOException;
21import java.util.Enumeration;
22import javax.servlet.*;
23import javax.servlet.http.*;
24
25/**
26 * Very Simple test servlet to test compression filter
27 * @author Amy Roh
28 * @version $Revision: 500668 $, $Date: 2007-01-28 00:07:51 +0100 (Sun, 28 Jan 2007) $
29 */
30
31public class CompressionFilterTestServlet extends HttpServlet {
32
33    public void doGet(HttpServletRequest request, HttpServletResponse response)
34        throws ServletException, IOException {
35
36        ServletOutputStream out = response.getOutputStream();
37        response.setContentType("text/plain");
38
39        Enumeration e = ((HttpServletRequest)request).getHeaders("Accept-Encoding");
40        while (e.hasMoreElements()) {
41            String name = (String)e.nextElement();
42            out.println(name);
43            if (name.indexOf("gzip") != -1) {
44                out.println("gzip supported -- able to compress");
45            }
46            else {
47                out.println("gzip not supported");
48            }
49        }
50
51
52        out.println("Compression Filter Test Servlet");
53        out.close();
54    }
55
56}
57
Note: See TracBrowser for help on using the repository browser.