List of usage examples for javax.servlet.http HttpServletResponse getOutputStream
public ServletOutputStream getOutputStream() throws IOException;
From source file:cs425.yogastudio.controller.CustomerController.java
@RequestMapping(value = "/customerpic/{id}", method = RequestMethod.GET) public void getUserImage(Model model, @PathVariable int id, HttpServletResponse response) { try {//from www .j av a 2s .com Customer c = customerService.get(id); if (c != null) { OutputStream out = response.getOutputStream(); out.write(c.getProductImage()); response.flushBuffer(); } } catch (IOException ex) { //Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.jxt.web.util.MappingJackson2JsonpView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { Object value = filterModel(model); JsonGenerator generator = this.objectMapper.getFactory().createGenerator(response.getOutputStream(), this.encoding); if (this.prefixJson) { generator.writeRaw("{} && "); }/* ww w .j a v a 2 s .c om*/ final String callBackParameter = getCallBackParameter(request); if (StringUtils.isEmpty(callBackParameter)) { this.objectMapper.writeValue(generator, value); } else { generator.writeRaw(callBackParameter); generator.writeRaw(cbPrefix); this.objectMapper.writeValue(generator, value); generator.writeRaw(cbSuffix); generator.writeRaw(cbEnd); } generator.flush(); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.IndividualListRdfController.java
private void sendEmptyModel(RdfResultMediaType mediaType, HttpServletResponse resp) throws IOException { resp.setContentType(mediaType.getContentType()); Model m = ModelFactory.createDefaultModel(); m.write(resp.getOutputStream(), mediaType.getJenaResponseFormat()); }
From source file:org.shimlib.web.servlet.view.filedownload.FileDownloadView.java
@Override protected void writeToResponse(HttpServletResponse response, ByteArrayOutputStream baos) throws IOException { response.setContentLength(baos.size()); // Flush byte array to servlet output stream. ServletOutputStream out = response.getOutputStream(); baos.writeTo(out);//from w w w . ja v a 2s .com out.flush(); }
From source file:org.envirocar.aggregation.AggregatedTracksServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { OutputStreamWriter writer = new OutputStreamWriter(resp.getOutputStream(), Charset.forName("UTF-8")); resp.setContentType("application/json"); String uri = req.getRequestURI(); String subPath = uri.substring(uri.indexOf(PATH) + PATH.length()); String trackId = null;/*from w w w.j a v a2s . co m*/ if (!subPath.isEmpty() && !(subPath.length() == 1 && subPath.equals("/"))) { trackId = subPath.startsWith("/") ? subPath.substring(1) : subPath; } String json; try { if (trackId != null) { json = createTrackExists(trackId); } else { json = createAggregatedTracksList(); } } catch (SQLException e) { throw new IOException(e); } writer.append(json); writer.flush(); writer.close(); resp.setStatus(200); }
From source file:org.wte4j.examples.showcase.server.services.GwtOrderServiceServlet.java
private void sendDocument(File file, HttpServletResponse resp) throws IOException { resp.setContentType(DOCUMENT_CONTENT_TYPE); resp.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName()); Files.copy(file, resp.getOutputStream()); }
From source file:com.controlj.green.bulktrend.trendserver.SearchServlet.java
private void writeErrorInRow(HttpServletResponse resp, String msg) throws IOException { ServletOutputStream out = resp.getOutputStream(); out.println("<tr><td colspan=\"100\">Error: " + msg + "</td></tr>"); out.flush();/*from w w w . j av a2 s .c o m*/ }
From source file:org.openxdata.server.servlet.StudyExportServlet.java
private void setBadRequest(HttpServletResponse response, String message) throws IOException { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("text/plain"); response.getOutputStream().println(message); }
From source file:edu.lafayette.metadb.web.search.SearchServlet.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */// w ww . j a v a2 s .c om protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF8"), true); JSONObject output = new JSONObject(); ArrayList<String> tokens = new ArrayList<String>(); try { String options = request.getParameter("search-options"); String projname = ""; String query = request.getParameter("query"); if (options.equals("current")) projname = (String) request.getSession(false).getAttribute(Global.SESSION_PROJECT); if (query != null && !query.equals("")) { ArrayList<Item> resultList = SearchDAO.search(projname, query); tokens.addAll(MetaDbHelper.getStringTokens(query)); output.put("size", resultList.size()); if (resultList.isEmpty()) output.put("data", "No entry found with query \"" + query + "\""); else output.put("data", this.getFormattedResult(resultList, tokens)); } else { output.put("data", "Please type in some keywords"); output.put("size", 0); } output.put("queries", tokens); out.print(output); } catch (Exception e) { MetaDbHelper.logEvent(e); } out.flush(); }
From source file:it.biztech.btable.api.OlapApi.java
@GET @Path("/getCubeStructure") @Produces("text/javascript") public void getCubeStructure(@QueryParam(MethodParams.CATALOG) String catalog, @QueryParam(MethodParams.CUBE) String cube, @QueryParam(MethodParams.JNDI) String jndi, @Context HttpServletResponse response) throws IOException, JSONException { OlapUtils olapUtils = new OlapUtils(); JSONObject result = olapUtils.getCubeStructure(catalog, cube, jndi); Utils.buildJsonResult(response.getOutputStream(), result != null, result); }