Example usage for javax.servlet.http HttpServletResponse flushBuffer

List of usage examples for javax.servlet.http HttpServletResponse flushBuffer

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse flushBuffer.

Prototype

public void flushBuffer() throws IOException;

Source Link

Document

Forces any content in the buffer to be written to the client.

Usage

From source file:edu.txstate.dmlab.clusteringwiki.rest.BaseRestController.java

/**
 * Send output back to the browser/* w  ww. ja v  a 2 s. c o m*/
 * @param response
 * @param resp
 */
protected void sendOutput(HttpServletResponse response, String resp) {
    try {
        response.getOutputStream().write(resp.getBytes());
        response.flushBuffer();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.codice.ddf.security.filter.authorization.AuthorizationFilter.java

/**
 * Sets status and error codes to forbidden and returns response.
 *
 * @param response/*from www . j a v  a2  s.  co  m*/
 */
private void returnNotAuthorized(HttpServletResponse response) {
    try {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        response.flushBuffer();
    } catch (IOException ioe) {
        LOGGER.debug("Failed to send auth response: {}", ioe);
    }

}

From source file:fr.putnami.pwt.plugin.ajaxbot.controller.SiteMapController.java

@RequestMapping(value = "/sitemap.txt", method = RequestMethod.GET)
public void welcomePage(HttpServletResponse response) {
    try {/*w w  w . j  a  va 2s  .co m*/
        InputStream is = new FileInputStream(sitemap);
        response.setContentType("text/plain");
        response.setContentLength((int) sitemap.length());
        IOUtils.copy(is, response.getOutputStream());
        response.flushBuffer();
    } catch (IOException ex) {
        throw new RuntimeException("IOError writing file to output stream", ex);
    }
}

From source file:com.example.multipart.MultipartServiceImpl.java

@Override
public void downloadByteArrayData(byte[] content, String contentType, String filename,
        HttpServletResponse response) throws IOException {

    InputStream is = new ByteArrayInputStream(content);

    response.setContentType(contentType);
    response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=\"" + filename + "\"");
    copy(is, response.getOutputStream());
    response.flushBuffer();
}

From source file:com.nec.harvest.security.handler.HarvestAuthenticationSuccessHandler.java

protected void sendRedirectToLogout(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType(HttpServletContentType.PLAN_TEXT);
    response.sendRedirect(request.getContextPath() + "/logout");
    response.flushBuffer();
}

From source file:com.surevine.alfresco.audit.integration.ResponseModifiableMockFilterChain.java

@Override
public void doFilter(final ServletRequest request, final ServletResponse response) {
    super.doFilter(request, response);

    try {//from  w  w w. j a  va2 s .  c o  m
        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
        httpServletResponse.getOutputStream().write(content.getBytes());
        httpServletResponse.setContentLength(content.length());
        httpServletResponse.setStatus(this.status);
        httpServletResponse.flushBuffer();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:arena.web.view.ErrorView.java

@SuppressWarnings("unchecked")
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    if (this.message != null) {
        response.setStatus(this.errorCode);
        response.getWriter()// ww w  .j  ava  2  s  .c o  m
                .append(ServletUtils.replaceWildcards(this.message, this.allowRequestArgs, model, request));
        response.flushBuffer();
    } else {
        response.sendError(this.errorCode);
    }
}

From source file:com.fishcart.delivery.service.OrderInformer.java

@RequestMapping(value = "/orderhistory", method = { RequestMethod.POST, RequestMethod.GET }, produces = {
        "application/text" })
public void getOrderHistory(@RequestParam(value = "date") String date, HttpServletResponse response)
        throws IOException {
    String data = generator.getOrderHistory(date);
    response.setHeader("Content-Disposition", "attachment; filename=report.csv");
    IOUtils.copy(IOUtils.toInputStream(data, "UTF-8"), response.getOutputStream());
    response.flushBuffer();
}

From source file:com.qcadoo.mes.workPlans.controller.WorkPlansController.java

private void printPdfFile(final Entity attachment, HttpServletResponse response) {
    InputStream is = fileService//w  w w.j  a  v a  2s  . c om
            .getInputStream(attachment.getStringField(TechnologyAttachmentFields.ATTACHMENT));
    try {
        IOUtils.copy(is, response.getOutputStream());
        response.flushBuffer();
    } catch (IOException e) {
        LOG.error("Problem with printing document - " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:cn.org.once.cstack.controller.MonitoringController.java

/**
 * Is a wrapper to cAdvisor API/* w w w .ja  v a  2s  .  com*/
 *
 * @return
 * @throws ServiceException
 * @throws CheckException
 */
@RequestMapping(value = "/api/machine", method = RequestMethod.GET)
public void infoMachine(HttpServletRequest request, HttpServletResponse response)
        throws ServiceException, CheckException {
    String responseFromCAdvisor = monitoringService.getJsonMachineFromCAdvisor();
    try {
        response.getWriter().write(responseFromCAdvisor);
        response.flushBuffer();
    } catch (Exception e) {
        logger.error("error during write and flush response", responseFromCAdvisor);
    }

}