亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? compressionservletresponsewrapper.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * CompressionServletResponseWrapper.java
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/servlet/filter/CompressionServletResponseWrapper.java,v 1.4 2004/04/30 03:15:06 drjavanomous Exp $
 * $Revision: 1.4 $
 * $Date: 2004/04/30 03:15:06 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */

package net.myvietnam.mvncore.servlet.filter;

import java.io.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

/**
 * Implementation of <b>HttpServletResponseWrapper</b> that works with
 * the CompressionServletResponseStream implementation..
 *
 * @author Amy Roh
 * @author Dmitri Valdin
 * @version $Revision: 1.4 $, $Date: 2004/04/30 03:15:06 $
 */

public class CompressionServletResponseWrapper extends HttpServletResponseWrapper {

    //minhnn : I remove the log because log4j does not support TRACE level
    //private static Log log = LogFactory.getLog(CompressionServletResponseWrapper.class);

    // ----------------------------------------------------- Constructor

    /**
     * Calls the parent constructor which creates a ServletResponse adaptor
     * wrapping the given response object.
     */

    public CompressionServletResponseWrapper(HttpServletResponse response) {
        super(response);
        origResponse = response;
        //log.trace("CompressionServletResponseWrapper constructor gets called");
    }


    // ----------------------------------------------------- Instance Variables

    /**
     * Original response
     */

    protected HttpServletResponse origResponse = null;

    /**
     * Descriptive information about this Response implementation.
     */

    protected static final String info = "CompressionServletResponseWrapper";

    /**
     * The ServletOutputStream that has been returned by
     * <code>getOutputStream()</code>, if any.
     */

    protected ServletOutputStream stream = null;


    /**
     * The PrintWriter that has been returned by
     * <code>getWriter()</code>, if any.
     */

    protected PrintWriter writer = null;

    /**
     * The threshold number to compress
     */
    protected int threshold = 0;

    /**
     * Debug level
     */
//    private int debug = 0;

    /**
     * Content type
     */
    protected String contentType = null;

    // --------------------------------------------------------- Public Methods


    /**
     * Set content type
     */
    public void setContentType(String contentType) {
        //log.trace("setContentType to " + contentType);
        this.contentType = contentType;
        origResponse.setContentType(contentType);
    }


    /**
     * Set threshold number
     */
    public void setCompressionThreshold(int threshold) {
        //log.trace("setCompressionThreshold to " + threshold);
        this.threshold = threshold;
    }


    /**
     * Set debug level
     */
//    public void setDebugLevel(int debug) {
//        this.debug = debug;
//    }


    /**
     * Create and return a ServletOutputStream to write the content
     * associated with this Response.
     *
     * @exception IOException if an input/output error occurs
     */
    public ServletOutputStream createOutputStream() throws IOException {
        //log.trace("createOutputStream gets called");

        CompressionResponseStream stream = new CompressionResponseStream(origResponse);
        //stream.setDebugLevel(debug);
        stream.setBuffer(threshold);

        return stream;

    }


    /**
     * Finish a response.
     */
    public void finishResponse() {
        try {
            if (writer != null) {
                writer.close();
            } else {
                if (stream != null)
                    stream.close();
            }
        } catch (IOException e) {
        }
    }


    // ------------------------------------------------ ServletResponse Methods


    /**
     * Flush the buffer and commit this response.
     *
     * @exception IOException if an input/output error occurs
     */
    public void flushBuffer() throws IOException {
        //log.trace("flush buffer @ CompressionServletResponseWrapper");

        // minhnn fix NullPointerException
        // this NPE occur when it filter a servlet mapping and then it later forward to not-exist jsp file
        if (stream != null) {
            //minhnn @todo : how to ensure the stream still open ???
            ((CompressionResponseStream)stream).flush();
        }

    }

    /**
     * Return the servlet output stream associated with this Response.
     *
     * @exception IllegalStateException if <code>getWriter</code> has
     *  already been called for this response
     * @exception IOException if an input/output error occurs
     */
    public ServletOutputStream getOutputStream() throws IOException {

        if (writer != null)
            throw new IllegalStateException("getWriter() has already been called for this response");

        if (stream == null) {
            stream = createOutputStream();
        }
        //log.trace("stream is set to " + stream + " in getOutputStream");

        return (stream);

    }

    /**
     * Return the writer associated with this Response.
     *
     * @exception IllegalStateException if <code>getOutputStream</code> has
     *  already been called for this response
     * @exception IOException if an input/output error occurs
     */
    public PrintWriter getWriter() throws IOException {

        if (writer != null)
            return (writer);

        if (stream != null)
            throw new IllegalStateException("getOutputStream() has already been called for this response");

        stream = createOutputStream();
        //log.trace("stream is set to " + stream + " in getWriter");
        //String charset = getCharsetFromContentType(contentType);
        String charEnc = origResponse.getCharacterEncoding();
        //log.trace("character encoding is " + charEnc);
        // HttpServletResponse.getCharacterEncoding() shouldn't return null
        // according the spec, so feel free to remove that "if"
        if (charEnc != null) {
            writer = new PrintWriter(new OutputStreamWriter(stream, charEnc));
        } else {
            writer = new PrintWriter(stream);
        }

        return (writer);

    }


    public void setContentLength(int length) {
    }


    /**
     * Returns character from content type. This method was taken from tomcat.
     * @author rajo
     */
    private static String getCharsetFromContentType(String type) {

        if (type == null) {
            return null;
        }
        int semi = type.indexOf(";");
        if (semi == -1) {
            return null;
        }
        String afterSemi = type.substring(semi + 1);
        int charsetLocation = afterSemi.indexOf("charset=");
        if(charsetLocation == -1) {
            return null;
        } else {
            String afterCharset = afterSemi.substring(charsetLocation + 8);
            String encoding = afterCharset.trim();
            return encoding;
        }
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产另类ts人妖一区二区| 91美女福利视频| 亚洲欧美另类久久久精品| 欧美人狂配大交3d怪物一区| 国产高清不卡一区二区| 亚洲在线中文字幕| 国产精品久久久久久久久免费相片| 在线不卡的av| 色综合婷婷久久| 国产91精品欧美| 久久91精品久久久久久秒播| 亚洲伊人色欲综合网| 国产精品无遮挡| 2020国产精品自拍| 日韩欧美久久一区| 欧美精品1区2区| 欧美少妇性性性| 色综合久久六月婷婷中文字幕| 国产一区二区三区在线看麻豆| 污片在线观看一区二区| 亚洲激情自拍视频| 日韩一区中文字幕| 自拍偷拍亚洲综合| 最新国产成人在线观看| 欧美国产成人在线| 久久精品人人爽人人爽| 精品国产99国产精品| 欧美一区二区三区视频在线| 欧美日免费三级在线| 色先锋aa成人| 91久久久免费一区二区| 91亚洲永久精品| 色综合网站在线| 91黄色在线观看| 在线观看日韩毛片| 欧美主播一区二区三区美女| 色综合欧美在线| 在线观看av不卡| 欧美日韩国产高清一区二区三区 | 国产不卡视频在线播放| 国产精品一区在线观看乱码| 久久国产精品露脸对白| 蜜臀av性久久久久蜜臀av麻豆| 日韩精品乱码av一区二区| 日韩精品欧美成人高清一区二区| 天天影视网天天综合色在线播放| 水蜜桃久久夜色精品一区的特点| 午夜精品久久久久久久久| 丝袜国产日韩另类美女| 久久超碰97人人做人人爱| 国产盗摄一区二区| 99久久精品国产一区| 一本一本大道香蕉久在线精品| 色婷婷久久久久swag精品| 欧美三级日本三级少妇99| 欧美日韩亚洲综合一区二区三区| 欧美日韩亚洲综合一区| 日韩一区二区中文字幕| 久久蜜桃香蕉精品一区二区三区| 国产视频一区在线播放| 最新国产成人在线观看| 亚洲777理论| 国产一区二区调教| 99re热视频这里只精品| 欧美日韩不卡在线| 久久久蜜桃精品| 亚洲毛片av在线| 免费观看成人av| yourporn久久国产精品| 欧美三级电影网站| 久久久不卡网国产精品二区| 综合电影一区二区三区| 婷婷综合另类小说色区| 国产福利一区在线观看| 欧美制服丝袜第一页| 日韩精品一区二区三区蜜臀 | 国产欧美va欧美不卡在线| 自拍偷拍国产精品| 免费高清在线视频一区·| 成人国产精品视频| 欧美一区午夜视频在线观看| 中文字幕高清不卡| 午夜伦欧美伦电影理论片| 成人一区二区三区| 欧美区在线观看| 国产精品色一区二区三区| 香蕉久久夜色精品国产使用方法 | 日韩成人av影视| 成人黄色av网站在线| 欧美精品 日韩| 亚洲美女在线国产| 国内精品视频666| 精品视频1区2区3区| 国产欧美日韩久久| 三级欧美在线一区| 一本大道综合伊人精品热热| 26uuuu精品一区二区| 午夜视频一区二区三区| 成人一区在线看| 精品久久久网站| 亚洲1区2区3区4区| 99riav一区二区三区| 久久久国际精品| 激情综合色播激情啊| 精品视频999| 一区二区三区资源| 成人免费看视频| 久久综合色婷婷| 日本最新不卡在线| 日本韩国一区二区三区| 中文字幕乱码亚洲精品一区| 日av在线不卡| 8x8x8国产精品| 亚洲自拍与偷拍| 91捆绑美女网站| 中文字幕不卡在线播放| 久久国产精品一区二区| 欧美美女网站色| 亚洲大片免费看| 欧美自拍丝袜亚洲| 亚洲精品国产一区二区三区四区在线 | 久久欧美一区二区| 美女看a上一区| 日韩免费电影一区| 日韩av一区二| 欧美日韩免费一区二区三区视频| 亚洲欧美在线另类| 不卡电影免费在线播放一区| 久久精品一区二区三区不卡牛牛| 麻豆精品一区二区综合av| 宅男在线国产精品| 日韩vs国产vs欧美| 日韩亚洲电影在线| 美女脱光内衣内裤视频久久网站| 欧美精品一二三| 日韩精品91亚洲二区在线观看 | 日韩一级二级三级| 美女脱光内衣内裤视频久久网站| 欧美一区二区三区电影| 日韩成人午夜电影| 日韩欧美国产三级| 精品一区二区三区的国产在线播放| 91麻豆精品国产91久久久资源速度| 天堂久久一区二区三区| 日韩一级黄色片| 国内成+人亚洲+欧美+综合在线| 精品国产91九色蝌蚪| 国内成人免费视频| 中文天堂在线一区| 91首页免费视频| 亚洲成人激情av| 欧美一级久久久| 国产成人精品三级| 自拍偷拍国产亚洲| 欧美精品精品一区| 国产毛片精品视频| 国产精品成人网| 欧美视频在线一区二区三区| 日精品一区二区三区| 精品国产麻豆免费人成网站| 国产成人在线观看| 一区二区高清视频在线观看| 欧美乱妇23p| 国产很黄免费观看久久| 亚洲色图制服丝袜| 这里只有精品电影| 国产宾馆实践打屁股91| 一卡二卡欧美日韩| 欧美一区二区三区男人的天堂| 国产一区二区视频在线| 亚洲欧美激情插 | 色一情一乱一乱一91av| 日韩成人av影视| 国产精品视频九色porn| 精品视频免费在线| 国产白丝精品91爽爽久久 | 亚洲精品国产第一综合99久久 | 国产麻豆成人精品| 亚洲精品ww久久久久久p站 | 久久一留热品黄| 在线看一区二区| 国产一区二区三区黄视频 | 亚洲图片欧美一区| 久久先锋影音av鲁色资源| 色婷婷av一区二区三区之一色屋| 秋霞影院一区二区| 《视频一区视频二区| 精品久久一区二区| 欧美性生交片4| 国产成人免费在线视频| 亚洲午夜精品17c| 国产性色一区二区| 欧美精品国产精品| 91蜜桃网址入口| 国产资源在线一区| 亚洲成人资源在线| 成人欧美一区二区三区白人| 日韩一区二区三区电影| 日韩欧美黄色影院| 欧美丝袜丝nylons|