01: /*
02: * Copyright 2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package compressionFilters;
18:
19: import java.io.IOException;
20: import java.io.PrintWriter;
21: import java.util.Enumeration;
22: import javax.servlet.*;
23: import javax.servlet.http.*;
24:
25: /**
26: * Very Simple test servlet to test compression filter
27: * @author Amy Roh
28: * @version $Revision: 1.2 $, $Date: 2004/03/18 16:40:33 $
29: */
30:
31: public class CompressionFilterTestServlet extends HttpServlet {
32:
33: public void doGet(HttpServletRequest request,
34: HttpServletResponse response) throws ServletException,
35: IOException {
36:
37: ServletOutputStream out = response.getOutputStream();
38: response.setContentType("text/plain");
39:
40: Enumeration e = ((HttpServletRequest) request)
41: .getHeaders("Accept-Encoding");
42: while (e.hasMoreElements()) {
43: String name = (String) e.nextElement();
44: out.println(name);
45: if (name.indexOf("gzip") != -1) {
46: out.println("gzip supported -- able to compress");
47: } else {
48: out.println("gzip not supported");
49: }
50: }
51:
52: out.println("Compression Filter Test Servlet");
53: out.close();
54: }
55:
56: }
|