Example #1
0
  @Override
  public void doAdvice(final HTTPRequestContext context, final Object ret) {
    final AbstractHTTPResponseRenderer renderer = context.getRenderer();
    if (null != renderer) {
      final Map<String, Object> dataModel = renderer.getRenderDataModel();

      dataModel.put(Common.CSRF_TOKEN, Sessions.getCSRFToken(context.getRequest()));
    }
  }
  /**
   * To http repsonse.
   *
   * @param context {@link HTTPRequestContext}
   * @throws IOException IOException
   */
  public static void result(final HTTPRequestContext context) throws IOException {
    final HttpServletResponse response = context.getResponse();

    if (response.isCommitted()) { // Sends rdirect or send error
      final PrintWriter writer = response.getWriter();

      writer.flush();
      writer.close();

      return;
    }

    AbstractHTTPResponseRenderer renderer = context.getRenderer();

    if (null == renderer) {
      renderer = new HTTP404Renderer();
    }

    renderer.render(context);
  }