List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:com.sivalabs.jcart.admin.web.controllers.ProductController.java
@GetMapping(value = "/products/images/{productId}") public void showProductImage(@PathVariable String productId, HttpServletRequest request, HttpServletResponse response) { try {/*from w w w . jav a 2s.c o m*/ FileSystemResource file = new FileSystemResource(IMAGES_DIR + productId + ".jpg"); response.setContentType("image/jpg"); copy(file.getInputStream(), response.getOutputStream()); response.flushBuffer(); } catch (IOException e) { log.error(e.getMessage(), e); } }
From source file:org.codice.ddf.security.handler.anonymous.AnonymousHandler.java
/** * This method handles errors related to failures related to credentials * verification. It returns a HTTP status code, 500 Internal Server Error, * which is then handled in Menu.view.js of the ddf-ui module. * * @param servletRequest http request to obtain attributes from and to pass into any local filter chains required * @param servletResponse http response to return http responses or redirects * @param chain original filter chain (should not be called from your handler) * @return HandlerResult//from w w w. j a v a 2 s . c o m * @throws ServletException */ @Override public HandlerResult handleError(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws ServletException { HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; httpResponse.setStatus(500); try { httpResponse.getWriter().write("Username/Password is invalid."); httpResponse.flushBuffer(); } catch (IOException e) { LOGGER.debug("Failed to send auth response: {}", e); } HandlerResult result = new HandlerResult(); LOGGER.debug("In error handler for anonymous - returning no action taken."); result.setStatus(HandlerResult.Status.NO_ACTION); return result; }
From source file:org.apache.cxf.fediz.service.idp.kerberos.KerberosEntryPoint.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex) throws IOException, ServletException { if (LOG.isDebugEnabled()) { LOG.debug("Sending back Negotiate Header for request: " + request.getRequestURL()); }/*from www.ja v a 2 s. c o m*/ response.addHeader("WWW-Authenticate", "Negotiate"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.flushBuffer(); }
From source file:org.dataconservancy.dcs.access.http.QueryServlet.java
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { CountingOutputStream countingOs = new CountingOutputStream(resp.getOutputStream()); search(req, resp, countingOs);/*from ww w .j a va2 s.co m*/ resp.setContentLength(countingOs.getCount()); resp.flushBuffer(); }
From source file:cz.muni.fi.pb138.cvmanager.controller.PDFcontroller.java
/** * Http Get request for "/auth/download" * Converts cv from xml format to latex and uploads pdf to users pc * * @param lang language of cv in downloaded pdf * @param response http server response// w ww .ja v a 2 s .c o m */ @RequestMapping(value = "/auth/download", method = RequestMethod.GET) public void downloadPDF(@RequestParam("l") String lang, HttpServletResponse response) { try { //uncomment the calling of method when login finished pdfGenerator.xmlToLatex(getPrincipalUsername(), lang); InputStream pdf = pdfGenerator.latexToPdf(getPrincipalUsername()); response.setContentType("application/pdf"); FileCopyUtils.copy(pdf, response.getOutputStream()); response.flushBuffer(); } catch (Exception ex) { System.out.print(ex.toString()); try { PrintWriter out = response.getWriter(); out.println("Sorry, generating of CV to PDF failed"); out.close(); } catch (Exception e) { System.out.print("not able to print on web site"); } } }
From source file:org.codice.ddf.security.handler.basic.AbstractBasicAuthenticationHandler.java
/** * Return a 401 response back to the web browser to prompt for basic auth. * * @param realm/*from ww w. j a va 2s . c o m*/ * @param response */ private void doAuthPrompt(String realm, HttpServletResponse response) { try { response.setHeader(HttpHeaders.WWW_AUTHENTICATE, AUTHENTICATION_SCHEME_BASIC + " realm=\"" + realm + "\""); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setContentLength(0); response.flushBuffer(); } catch (IOException ioe) { LOGGER.debug("Failed to send auth response: {}", ioe); } }
From source file:dk.dma.msiproxy.web.MessageDetailsServlet.java
/** * Generates a HTML page containing the MSI message details * @param request the HTTP servlet request * @param response the HTTP servlet response *///w w w . j ava 2s .c om private void generateHtmlPage(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Normal processing request.getRequestDispatcher(DETAILS_JSP_FILE).include(request, response); response.flushBuffer(); }
From source file:org.alfresco.repo.webdav.auth.HTTPRequestAuthenticationFilter.java
private void reject(HttpServletRequest httpReq, HttpServletResponse httpResp) throws IOException { httpResp.setHeader("WWW-Authenticate", "BASIC realm=\"Alfresco DAV Server\""); httpResp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); httpResp.flushBuffer(); return;/* w ww . ja v a 2 s . c o m*/ }
From source file:be.dnsbelgium.rdap.spring.security.RDAPErrorHandler.java
@Override public final void handle(final HttpServletRequest request, final HttpServletResponse response, final AccessDeniedException e) throws IOException, ServletException { if (e instanceof RDAPErrorException) { response.setContentType(Controllers.CONTENT_TYPE); RDAPErrorException exception = (RDAPErrorException) e; response.setStatus(exception.getErrorCode()); mapper.writeValue(response.getOutputStream(), exception); response.flushBuffer(); } else {//from w w w . j av a 2s . c o m super.handle(request, response, e); } }