001    /*
002    * Licensed to the Apache Software Foundation (ASF) under one or more
003    * contributor license agreements.  See the NOTICE file distributed with
004    * this work for additional information regarding copyright ownership.
005    * The ASF licenses this file to You under the Apache License, Version 2.0
006    * (the "License"); you may not use this file except in compliance with
007    * the License.  You may obtain a copy of the License at
008    *
009    *     http://www.apache.org/licenses/LICENSE-2.0
010    *
011    * Unless required by applicable law or agreed to in writing, software
012    * distributed under the License is distributed on an "AS IS" BASIS,
013    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014    * See the License for the specific language governing permissions and
015    * limitations under the License.
016    */
017    
018    package compressionFilters;
019    
020    import java.io.IOException;
021    import java.util.Enumeration;
022    
023    import javax.servlet.ServletException;
024    import javax.servlet.ServletOutputStream;
025    import javax.servlet.http.HttpServlet;
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * Very Simple test servlet to test compression filter
031     *
032     * @author Amy Roh
033     * @version $Revision: 664175 $, $Date: 2008-06-06 18:43:44 -0400 (Fri, 06 Jun 2008) $
034     */
035    
036    public class CompressionFilterTestServlet extends HttpServlet {
037    
038        public void doGet(HttpServletRequest request, HttpServletResponse response)
039                throws ServletException, IOException {
040    
041            ServletOutputStream out = response.getOutputStream();
042            response.setContentType("text/plain");
043    
044            Enumeration e = ((HttpServletRequest) request).getHeaders("Accept-Encoding");
045            while (e.hasMoreElements()) {
046                String name = (String) e.nextElement();
047                out.println(name);
048                if (name.indexOf("gzip") != -1) {
049                    out.println("gzip supported -- able to compress");
050                } else {
051                    out.println("gzip not supported");
052                }
053            }
054    
055    
056            out.println("Compression Filter Test Servlet");
057            out.close();
058        }
059    
060    }
061