Beispiel #1
0
  private boolean dispatch(Writer out, String page, Map params, int mode, boolean include)
      throws IOException, ServletException {
    // FUTURE: handle if ~./, PASS_THRU_ATTR and with query string
    // In other words, we convert query string to params if
    // PASS_THRU_ATTR and ~./ (to have a better performance)
    if ((mode != PASS_THRU_ATTR && params != null)
        || !page.startsWith("~./")
        || page.indexOf('?') >= 0) return false;

    // Bug 1801028: We cannot invoke ZumlExtendlet directly
    // The real reason is unknown yet -- it could be due to
    // the re-creation of ExecutionImpl
    // However, the performance is not a major issue, so just skip
    final ClassWebResource cwr = WebManager.getWebManager(_ctx).getClassWebResource();
    if (!isDirectInclude(cwr, page)) return false;

    Object old = null;
    if (mode == PASS_THRU_ATTR) {
      old = _request.getAttribute(Attributes.ARG);
      if (params != null) _request.setAttribute(Attributes.ARG, params);
      // If params=null, use the 'inherited' one (same as Servlets.include)
    }

    final String attrnm =
        include ? "org.zkoss.web.servlet.include" : "org.zkoss.web.servlet.forward";
    _request.setAttribute(attrnm, Boolean.TRUE);
    // so Servlets.isIncluded returns correctly
    try {
      cwr.service(_request, HttpBufferedResponse.getInstance(_response, out), page.substring(2));
    } finally {
      _request.removeAttribute(attrnm);
      if (mode == PASS_THRU_ATTR) _request.setAttribute(Attributes.ARG, old);
    }

    return true;
  }
Beispiel #2
0
 WebApp getWebApp() {
   return _webctx != null
       ? WebManager.getWebManager(_webctx.getServletContext()).getWebApp()
       : null;
 }