List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:com.ewcms.publication.filter.render.ResourceRender.java
/** * ?/*from w w w .j ava 2 s . co m*/ * * @param response * @param uri ? * @return * @throws IOException */ @Override protected boolean output(HttpServletResponse response, Long siteId, String uri) throws IOException { Resource resource = resourcePublishDao.findByUri(siteId, uri); if (resource == null) { logger.debug("Resource is not exist,uri is {}", uri); return false; } String realPath = resource.getPath(); try { IOUtils.copy(new FileInputStream(realPath), response.getOutputStream()); } catch (Exception e) { logger.warn("Resource is not exit,real path is{}", realPath); } response.flushBuffer(); return true; }
From source file:com.qubit.solution.fenixedu.bennu.webservices.ui.management.keystores.DomainKeyStoreController.java
@RequestMapping(value = "/read/{oid}/downloadkeystore") public void processReadToDownloadKeystore(@PathVariable("oid") DomainKeyStore domainKeyStore, HttpServletResponse response) { InputStream is = domainKeyStore.getKeyStoreFile().getStream(); response.setContentType("application/octet-stream"); response.setHeader("Content-disposition", "attachment; filename=" + domainKeyStore.getName() + ".jks"); try {/*from ww w. java2 s. co m*/ StreamUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.fao.unredd.portal.ApplicationController.java
@RequestMapping("/charts.json") public void getCharts(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("application/json;charset=UTF-8"); try {//from ww w .j a va 2 s . c o m response.getWriter().print(getCharts()); response.flushBuffer(); } catch (Exception e) { logger.error(e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:com.cognifide.aet.rest.LockServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("GET: " + req.toString()); }/* w w w . j a va 2 s . c om*/ resp.setContentType(APPLICATION_JSON_CONTENT_TYPE); String key = getKey(req); if (StringUtils.isBlank(key)) { resp.getWriter().write(GSON.toJson(getLocks())); } else { resp.getWriter().write(GSON.toJson(lockService.isLockPresent(key))); } resp.flushBuffer(); }
From source file:waffle.spring.NegotiateSecurityFilterEntryPoint.java
@Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException ex) throws IOException, ServletException { NegotiateSecurityFilterEntryPoint.LOGGER.debug("[waffle.spring.NegotiateEntryPoint] commence"); if (this.provider == null) { throw new ServletException("Missing NegotiateEntryPoint.Provider"); }//from ww w.j av a 2s .c o m response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setHeader("Connection", "keep-alive"); this.provider.sendUnauthorized(response); response.flushBuffer(); }
From source file:org.codice.ddf.security.idp.client.IdpHandler.java
private void doHttpPostBinding(HttpServletRequest request, HttpServletResponse response) throws ServletException { try {/*from w ww.j av a2s. c o m*/ response.getWriter().printf(postBindingTemplate, idpMetadata.getSingleSignOnLocation(), createAuthnRequest(true), createRelayState(request)); response.setStatus(200); response.flushBuffer(); } catch (IOException e) { LOGGER.warn("Unable to post AuthnRequest to IdP", e); throw new ServletException("Unable to post to IdP"); } }
From source file:com.norconex.collector.http.website.TestServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String testCaseKey = StringUtils.trimToNull(req.getParameter("case")); if (StringUtils.isBlank(testCaseKey)) { testCaseKey = "list"; }//from ww w . j a v a2 s. c om TestCase testCase = testCases.get(testCaseKey); if (testCase == null) { testCase = testCases.get("list"); } try { testCase.doTestCase(req, resp); resp.flushBuffer(); } catch (Exception e) { e.printStackTrace(resp.getWriter()); } }
From source file:cn.lhfei.fu.web.controller.HomeworkController.java
/** * Method for handling file download request from client *//* www . ja v a 2s. c o m*/ @RequestMapping(method = RequestMethod.GET) public void doDownload(HttpServletRequest request, HttpServletResponse response) throws IOException { try { // get your file as InputStream InputStream is = null; // copy it to response's OutputStream org.apache.commons.io.IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { throw new RuntimeException("IOError writing file to output stream"); } }
From source file:com.google.nigori.server.NigoriServlet.java
/** * Send an SC_OK and and empty body/*w w w .j a v a 2 s. com*/ * * @param resp * @throws ServletException */ private void emptyBody(HttpServletResponse resp) throws ServletException { try { resp.setContentType(MessageLibrary.MIMETYPE_JSON); resp.setStatus(HttpServletResponse.SC_OK); resp.flushBuffer(); } catch (IOException ioe) { throw new ServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error attempting to write status OK message after successfully handling a PutRequest"); } }
From source file:com.almende.eve.transport.http.DebugServlet.java
@Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws IOException, ServletException { if (!handleSession(req, resp)) { if (!resp.isCommitted()) { resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); }/*from w ww. j av a2s . c om*/ resp.flushBuffer(); return; } // retrieve the url and the request body final String body = StringUtil.streamToString(req.getInputStream()); final String url = req.getRequestURI(); final String id = getId(url); if (id == null || id.equals("") || id.equals(myUrl.toASCIIString())) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Couldn't parse URL, missing 'id'"); resp.flushBuffer(); return; } String sender = req.getHeader("X-Eve-SenderUrl"); if (sender == null || sender.equals("")) { sender = "web://" + req.getRemoteUser() + "@" + req.getRemoteAddr(); } URI senderUrl = null; try { senderUrl = new URI(sender); } catch (final URISyntaxException e) { LOG.log(Level.WARNING, "Couldn't parse senderUrl:" + sender, e); } final HttpTransport transport = HttpService.get(myUrl, id); if (transport != null) { try { final String response = transport.receive(body, senderUrl); // TODO: It doesn't need to be json, should we handle mime-types // better? resp.addHeader("Content-Type", "application/json"); resp.getWriter().println(response); resp.getWriter().close(); } catch (final IOException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Receiver raised exception:" + e.getMessage()); } } else { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Couldn't load transport"); } resp.flushBuffer(); }