⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controlservlet.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        Security security = (Security) session.getAttribute("security");        if (security == null) {            security = (Security) getServletContext().getAttribute("security");        }        if (security == null) {            Debug.logError("[ControlServlet] ERROR: security not found in ServletContext", module);        }        request.setAttribute("security", security);        // display details on the servlet objects        if (Debug.verboseOn()) {            logRequestInfo(request);        }        if (Debug.timingOn()) timer.timerString("[" + rname + "] Setup done, doing Event(s) and View(s)", module);        // some containers call filters on EVERY request, even forwarded ones, so let it know that it came from the control servlet        request.setAttribute(ContextFilter.FORWARDED_FROM_SERVLET, new Boolean(true));        String errorPage = null;        try {            // the ServerHitBin call for the event is done inside the doRequest method            getRequestHandler().doRequest(request, response, null, userLogin, delegator);        } catch (RequestHandlerException e) {            Throwable throwable = e.getNested() != null ? e.getNested() : e;            Debug.logError(throwable, "Error in request handler: ", module);            request.setAttribute("_ERROR_MESSAGE_", throwable.toString());            errorPage = getRequestHandler().getDefaultErrorPage(request);        } catch (Exception e) {            Debug.logError(e, "Error in request handler: ", module);            request.setAttribute("_ERROR_MESSAGE_", e.toString());            errorPage = getRequestHandler().getDefaultErrorPage(request);        }        // Forward to the JSP        // if (Debug.infoOn()) Debug.logInfo("[" + rname + "] Event done, rendering page: " + nextPage, module);        // if (Debug.timingOn()) timer.timerString("[" + rname + "] Event done, rendering page: " + nextPage, module);        if (errorPage != null) {            Debug.logError("An error occurred, going to the errorPage: " + errorPage, module);            RequestDispatcher rd = request.getRequestDispatcher(errorPage);            // use this request parameter to avoid infinite looping on errors in the error page...            if (request.getAttribute("_ERROR_OCCURRED_") == null && rd != null) {                request.setAttribute("_ERROR_OCCURRED_", new Boolean(true));                Debug.logError("Including errorPage: " + errorPage, module);                rd.include(request, response);                /* For some reason (with Tomcat only?) this isn't making it to the browser, and neither is the rd.include...                String errorMessage = "<html><body>ERROR in error page, (infinite loop or error page not found with name [" + errorPage + "]), but here is the text just in case it helps you: " + request.getAttribute("ERROR_MESSAGE_") + "</body></html>";                if (UtilJ2eeCompat.useOutputStreamNotWriter(getServletContext())) {                    response.getOutputStream().print(errorMessage);                } else {                    response.getWriter().print(errorMessage);                }                */            } else {                if (rd == null) {                    Debug.logError("Could not get RequestDispatcher for errorPage: " + errorPage, module);                }                String errorMessage = "<html><body>ERROR in error page, (infinite loop or error page not found with name [" + errorPage + "]), but here is the text just in case it helps you: " + request.getAttribute("ERROR_MESSAGE_") + "</body></html>";                if (UtilJ2eeCompat.useOutputStreamNotWriter(getServletContext())) {                    response.getOutputStream().print(errorMessage);                } else {                    response.getWriter().print(errorMessage);                }            }        }        // sanity check; make sure we don't have any transactions in place        try {            // roll back current TX first            if (TransactionUtil.isTransactionInPlace()) {                Debug.logWarning("*** NOTICE: ControlServlet finished w/ a transaction in place! Rolling back.", module);                TransactionUtil.rollback();            }            // now resume/rollback any suspended txs            if (TransactionUtil.suspendedTransactionsHeld()) {                int suspended = TransactionUtil.cleanSuspendedTransactions();                Debug.logWarning("Resumed/Rolled Back [" + suspended + "] transactions.", module);            }        } catch (GenericTransactionException e) {            Debug.logWarning(e, module);        }        ServerHitBin.countRequest(webappName + "." + rname, request, requestStartTime, System.currentTimeMillis() - requestStartTime, userLogin, delegator);        if (Debug.timingOn()) timer.timerString("[" + rname + "] Done rendering page, Servlet Finished", module);    }    /**     * @see javax.servlet.Servlet#destroy()     */    public void destroy() {        super.destroy();    }    protected RequestHandler getRequestHandler() {        return RequestHandler.getRequestHandler(getServletContext());    }    protected void configureBsf() {        String[] bshExtensions = {"bsh"};        BSFManager.registerScriptingEngine("beanshell", "org.ofbiz.base.util.OfbizBshBsfEngine", bshExtensions);        String[] jsExtensions = {"js"};        BSFManager.registerScriptingEngine("javascript", "org.ofbiz.base.util.OfbizJsBsfEngine", jsExtensions);        String[] smExtensions = {"sm"};        BSFManager.registerScriptingEngine("simplemethod", "org.ofbiz.minilang.SimpleMethodBsfEngine", smExtensions);    }    protected void logRequestInfo(HttpServletRequest request) {        ServletContext servletContext = this.getServletContext();        HttpSession session = request.getSession();        Debug.logVerbose("--- Start Request Headers: ---", module);        Enumeration headerNames = request.getHeaderNames();        while (headerNames.hasMoreElements()) {            String headerName = (String) headerNames.nextElement();            Debug.logVerbose(headerName + ":" + request.getHeader(headerName), module);        }        Debug.logVerbose("--- End Request Headers: ---", module);        Debug.logVerbose("--- Start Request Parameters: ---", module);        Enumeration paramNames = request.getParameterNames();        while (paramNames.hasMoreElements()) {            String paramName = (String) paramNames.nextElement();            Debug.logVerbose(paramName + ":" + request.getParameter(paramName), module);        }        Debug.logVerbose("--- End Request Parameters: ---", module);        Debug.logVerbose("--- Start Request Attributes: ---", module);        Enumeration reqNames = request.getAttributeNames();        while (reqNames != null && reqNames.hasMoreElements()) {            String attName = (String) reqNames.nextElement();            Debug.logVerbose(attName + ":" + request.getAttribute(attName), module);        }        Debug.logVerbose("--- End Request Attributes ---", module);        Debug.logVerbose("--- Start Session Attributes: ---", module);        Enumeration sesNames = null;        try {            sesNames = session.getAttributeNames();        } catch (IllegalStateException e) {            Debug.logVerbose("Cannot get session attributes : " + e.getMessage(), module);        }        while (sesNames != null && sesNames.hasMoreElements()) {            String attName = (String) sesNames.nextElement();            Debug.logVerbose(attName + ":" + session.getAttribute(attName), module);        }        Debug.logVerbose("--- End Session Attributes ---", module);        Enumeration appNames = servletContext.getAttributeNames();        Debug.logVerbose("--- Start ServletContext Attributes: ---", module);        while (appNames != null && appNames.hasMoreElements()) {            String attName = (String) appNames.nextElement();            Debug.logVerbose(attName + ":" + servletContext.getAttribute(attName), module);        }        Debug.logVerbose("--- End ServletContext Attributes ---", module);    }}

⌨️ 快捷键说明

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