Examples of JWebLiteResponseWrapper


Examples of jweblite.web.wrapper.JWebLiteResponseWrapper

          req.getRequestURI(), req.getQueryString()));
    }
    String encoding = filterConfig.getEncoding();
    String attrPrefix = filterConfig.getAttrPrefix();
    // wrap response
    JWebLiteResponseWrapper respWrapper = null;
    if (resp instanceof JWebLiteResponseWrapper) {
      respWrapper = (JWebLiteResponseWrapper) resp;
    } else {
      respWrapper = new JWebLiteResponseWrapper(req, resp, encoding,
          filterConfig.isGZipEnabled());
    }
    WebContext context = new WebContext(req, respWrapper);
    // prepare default variables
    req.setAttribute(attrPrefix.concat("CP"), req.getContextPath());
    // session manager
    req.getSession(true).setAttribute(attrPrefix.concat("SessionManager"),
        JWebLiteSessionManager.get());
    try {
      // parse form model
      String formModelAttrName = attrPrefix.concat("FM");
      FormModel formModel = (FormModel) req
          .getAttribute(formModelAttrName);
      if (formModel == null) {
        formModel = new FormModel(req, encoding);
      }
      req.setAttribute(formModelAttrName, formModel);
      // starting
      boolean isIgnoreTemplate = false;
      JWebLitePage reqClassInstance = null;
      try {
        // trigger doBeforeRequest event
        application.doBeforeRequest(context, formModel);
        // init class
        reqClassInstance = doRequest(context, formModel);
      } catch (SkipException se) {
        isIgnoreTemplate = true;
      }
      // listener
      doListener(respWrapper, reqClassInstance);
      // pass the request along the filter chain
      if (!isIgnoreTemplate) {
        // trigger doBeforeRender event
        application.doBeforeRender(context, formModel);
        chain.doFilter(req, respWrapper);
      }
      // trigger doAfterRequest event
      application.doAfterRequest(context, formModel);
      // do finish
      respWrapper.doFinish();
    } catch (Throwable e) {
      _cat.warn("Do filter failed!", e);
      application.doError(context, e);
      doErrorPage(filterConfig, req, respWrapper, e);
    }
View Full Code Here

Examples of jweblite.web.wrapper.JWebLiteResponseWrapper

      IOException {
    if (servletPath == null) {
      return "";
    }
    // original wrapper stream
    JWebLiteResponseWrapper respWrapper = (JWebLiteResponseWrapper) resp;
    JWebLiteResponseWrapperStream respWrapperStream = respWrapper
        .getWrapperStream();
    OutputStream originalOutputStream = respWrapperStream
        .getOriginalOutputStream();
    // proxy
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    respWrapperStream.setGZipEnabled(false);
    respWrapperStream.resetOutputStream(baos);
    req.getRequestDispatcher(servletPath).forward(req, resp);
    // revert
    respWrapperStream.setGZipEnabled(respWrapper.isGZipEnabled());
    respWrapperStream.resetOutputStream(originalOutputStream);
    return baos.toString();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.