Esempio n. 1
0
  /** Prepares response to the file upload */
  protected void sendResponse(
      ServletWebRequest webRequest, WebResponse webResponse, List<FileItem> fileItems)
      throws FileUploadException, IOException {

    String accept = webRequest.getHeader("Accept");
    if (wantsHtml(accept)) {
      // Internet Explorer
      RequestCycle.get()
          .scheduleRequestHandlerAfterCurrent(
              new TextRequestHandler(
                  "text/html",
                  "utf-8",
                  escapeHtml(generateJsonResponse(webRequest, webResponse, fileItems))));
    } else {
      // A real browser
      RequestCycle.get()
          .scheduleRequestHandlerAfterCurrent(
              new TextRequestHandler(
                  "application/json",
                  "utf-8",
                  generateJsonResponse(webRequest, webResponse, fileItems)));
    }
  }