Source Code Cross Referenced for GZIPResponseStream.java in  » GIS » deegree » org » deegree » enterprise » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » deegree » org.deegree.enterprise.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/enterprise/servlet/GZIPResponseStream.java $
002:        /*
003:         This file is part of deegree.
004:         Copyright (C) 2001-2008 by:
005:         EXSE, Department of Geography, University of Bonn
006:         http://www.giub.uni-bonn.de/deegree/
007:         lat/lon GmbH
008:         http://www.lat-lon.de
009:
010:         This library is free software; you can redistribute it and/or
011:         modify it under the terms of the GNU Lesser General Public
012:         License as published by the Free Software Foundation; either
013:         version 2.1 of the License, or (at your option) any later version.
014:
015:         This library is distributed in the hope that it will be useful,
016:         but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
018:         Lesser General Public License for more details.
019:
020:         You should have received a copy of the GNU Lesser General Public
021:         License along with this library; if not, write to the Free Software
022:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
023:
024:         Contact:
025:
026:         Andreas Poth
027:         lat/lon GmbH
028:         Aennchenstr. 19
029:         53115 Bonn
030:         Germany
031:         E-Mail: poth@lat-lon.de
032:
033:         Prof. Dr. Klaus Greve
034:         Department of Geography
035:         University of Bonn
036:         Meckenheimer Allee 166
037:         53115 Bonn
038:         Germany
039:         E-Mail: greve@giub.uni-bonn.de
040:        
041:         Copyright 2003 Jayson Falkner (jayson@jspinsider.com)
042:         This code is from "Servlets and JavaServer pages; the J2EE Web Tier",
043:         http://www.jspbook.com.
044:         */
045:        package org.deegree.enterprise.servlet;
046:
047:        import java.io.ByteArrayOutputStream;
048:        import java.io.IOException;
049:        import java.util.zip.GZIPOutputStream;
050:
051:        import javax.servlet.ServletOutputStream;
052:        import javax.servlet.http.HttpServletResponse;
053:
054:        /**
055:         * 
056:         * 
057:         * 
058:         * @version $Revision: 9338 $
059:         * @author <a href="mailto:jayson@jspinsider.com">Jayson Falkner</a>
060:         * @author last edited by: $Author: apoth $
061:         * 
062:         * @version 1.0. $Revision: 9338 $, $Date: 2007-12-27 04:31:31 -0800 (Thu, 27 Dec 2007) $
063:         * 
064:         * @since 2.0
065:         */
066:        public class GZIPResponseStream extends ServletOutputStream {
067:            protected ByteArrayOutputStream baos = null;
068:
069:            protected GZIPOutputStream gzipstream = null;
070:
071:            protected boolean closed = false;
072:
073:            protected HttpServletResponse response = null;
074:
075:            protected ServletOutputStream output = null;
076:
077:            /**
078:             * 
079:             * @param response
080:             * @throws IOException
081:             */
082:            public GZIPResponseStream(HttpServletResponse response)
083:                    throws IOException {
084:                super ();
085:                closed = false;
086:                this .response = response;
087:                this .output = response.getOutputStream();
088:                baos = new ByteArrayOutputStream();
089:                gzipstream = new GZIPOutputStream(baos);
090:            }
091:
092:            /**
093:             * @throws IOException
094:             */
095:            public void close() throws IOException {
096:                if (closed) {
097:                    throw new IOException(
098:                            "This output stream has already been closed");
099:                }
100:                gzipstream.finish();
101:
102:                byte[] bytes = baos.toByteArray();
103:
104:                response.addHeader("Content-Length", Integer
105:                        .toString(bytes.length));
106:                response.addHeader("Content-Encoding", "gzip");
107:                output.write(bytes);
108:                output.flush();
109:                output.close();
110:                closed = true;
111:            }
112:
113:            /**
114:             * @throws IOException
115:             */
116:            public void flush() throws IOException {
117:                if (closed) {
118:                    throw new IOException("Cannot flush a closed output stream");
119:                }
120:                gzipstream.flush();
121:            }
122:
123:            /**
124:             * @param b
125:             *            data to write
126:             * @throws IOException
127:             */
128:            public void write(int b) throws IOException {
129:                if (closed) {
130:                    throw new IOException(
131:                            "Cannot write to a closed output stream");
132:                }
133:                gzipstream.write((byte) b);
134:            }
135:
136:            /**
137:             * @param b
138:             *            data array to write
139:             * @throws IOException
140:             */
141:            public void write(byte b[]) throws IOException {
142:                write(b, 0, b.length);
143:            }
144:
145:            /**
146:             * @param b
147:             *            data array to write
148:             * @param off
149:             *            index of the for byte
150:             * @param len
151:             *            number of bytes to write
152:             * @throws IOException
153:             */
154:            public void write(byte b[], int off, int len) throws IOException {
155:                System.out.println("writing...");
156:                if (closed) {
157:                    throw new IOException(
158:                            "Cannot write to a closed output stream");
159:                }
160:                gzipstream.write(b, off, len);
161:            }
162:
163:            /**
164:             * 
165:             * @return true if already has been closed
166:             */
167:            public boolean closed() {
168:                return (this .closed);
169:            }
170:
171:            /**
172:             * 
173:             * 
174:             */
175:            public void reset() {
176:                // noop
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.