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 import javax.servlet.*; 023 import javax.servlet.http.*; 024 025 /** 026 * Very Simple test servlet to test compression filter 027 * @author Amy Roh 028 * @version $Revision: 514091 $, $Date: 2007-03-03 01:26:39 -0500 (Sat, 03 Mar 2007) $ 029 */ 030 031 public class CompressionFilterTestServlet extends HttpServlet { 032 033 public void doGet(HttpServletRequest request, HttpServletResponse response) 034 throws ServletException, IOException { 035 036 ServletOutputStream out = response.getOutputStream(); 037 response.setContentType("text/plain"); 038 039 Enumeration e = ((HttpServletRequest)request).getHeaders("Accept-Encoding"); 040 while (e.hasMoreElements()) { 041 String name = (String)e.nextElement(); 042 out.println(name); 043 if (name.indexOf("gzip") != -1) { 044 out.println("gzip supported -- able to compress"); 045 } 046 else { 047 out.println("gzip not supported"); 048 } 049 } 050 051 052 out.println("Compression Filter Test Servlet"); 053 out.close(); 054 } 055 056 } 057