Пример #1
0
  /**
   * Dispatches the specified request to the specified article or page processor with the specified
   * response.
   *
   * @param request the specified request
   * @param response the specified response
   * @param article the specified article
   * @param page the specified page
   * @throws ServletException servlet exception
   * @throws IOException io exception
   * @see HTTPRequestDispatcher#dispatch(org.b3log.latke.servlet.HTTPRequestContext)
   */
  private void dispatchToArticleOrPageProcessor(
      final ServletRequest request,
      final ServletResponse response,
      final JSONObject article,
      final JSONObject page)
      throws ServletException, IOException {
    final HTTPRequestContext context = new HTTPRequestContext();
    context.setRequest((HttpServletRequest) request);
    context.setResponse((HttpServletResponse) response);

    if (null != article) {
      request.setAttribute(Article.ARTICLE, article);
      request.setAttribute(Keys.HttpRequest.REQUEST_URI, Juggs.getContextPath() + "/article");
    } else {
      request.setAttribute(Page.PAGE, page);
      request.setAttribute(Keys.HttpRequest.REQUEST_URI, Juggs.getContextPath() + "/page");
    }

    request.setAttribute(Keys.HttpRequest.REQUEST_METHOD, HTTPRequestMethod.GET.name());

    HTTPRequestDispatcher.dispatch(context);
  }