001 /* 002 * Copyright 2004 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package compressionFilters; 018 019 import java.io.IOException; 020 import java.io.PrintWriter; 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: 267129 $, $Date: 2004-03-18 08:40:35 -0800 (Thu, 18 Mar 2004) $ 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