Java Code Examples for org.apache.log4j.lf5.util.StreamUtils

The following examples show how to use org.apache.log4j.lf5.util.StreamUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{
  log.debug("Start doPost");
  try {
    // Inputstream
    final InputStream is = request.getInputStream();
    final byte[] buffer = StreamUtils.getBytes(is);
    String filename;
    String croppedname;
    if (request.getParameter("croppedname") != null) {
      croppedname = request.getParameter("croppedname");
    } else {
      croppedname = "cropped";
    }
    if ((request.getParameter("filename") != null) && (request.getParameter("filetype") != null)) {
      filename = croppedname + request.getParameter("filename") + "." + request.getParameter("filetype");
    } else {
      filename = "image.png";
    }
    log.info("Filename: " + filename);
    ResponseUtils.streamToOut(filename, buffer, response, request.getSession().getServletContext(), true);
  } catch (Exception ex) {
    log.warn("Failure reading the request");
    log.warn(ex.getMessage(), ex);
  }
}