blockingfilter.java

来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· Java 代码 · 共 62 行

JAVA
62
字号
/* * $RCSFile$ * $Revision: 1.5 $ * $Date: 2002/07/14 15:44:39 $ * * Copyright (C) 1999-2002 Jive Software. All rights reserved. * * This software is the proprietary information of Jive Software. * Use is subject to license terms. */package com.jivesoftware.util;import java.io.*;import javax.servlet.*;import com.jivesoftware.forum.*;public class BlockingFilter implements javax.servlet.Filter {    private String errorPage = "/error.html";    public void init(FilterConfig filterConfig) throws ServletException {        // Load up an optional error page        String errorPageParam = filterConfig.getInitParameter("errorPage");        if (errorPageParam != null) {            errorPage = errorPageParam;        }    }    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException    {        boolean isBlocking = false;        // Check the value of the Jive property "blockTraffic". It tells        // us if we need to change the mode we're in:        if ("true".equals(JiveGlobals.getJiveProperty("blockTraffic"))) {            isBlocking = true;        }        else {            isBlocking = false;        }        if (isBlocking) {            response.setContentType("text/html");            RequestDispatcher rd = request.getRequestDispatcher(errorPage);            rd.include(request, response);            return;        }        else {            // Move on..            chain.doFilter(request, response);        }    }    public void destroy() {        // Do nothing for now.    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?