Refine search
@Override public void setHeader(String name, String value) { super.setHeader(name, value); }
@Override public void addHeader(String name, String value) { super.addHeader(name, value); }
/** * Applies content type to the response. * Called before output stream or a writer are used. */ private void applyContentType() { if (mimeType != null) { super.setContentType(mimeType); if (characterEncoding != null) { super.setCharacterEncoding(characterEncoding); } } }
@RequestMapping(value = "jsonDemoDude", method = RequestMethod.GET) public void getCssForElasticSearchConfiguration(HttpServletResponse response) throws IOException { String jsonContent= ...; HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(response); wrapper.setContentType("application/json;charset=UTF-8"); wrapper.setHeader("Content-length", "" + jsonContent.getBytes().length); response.getWriter().print(jsonContent); }
@Override public PrintWriter getWriter() throws IOException { // From cmurphy@intechtual.com to fix: // https://appfuse.dev.java.net/issues/show_bug.cgi?id=59 if (this.origResponse != null && this.origResponse.isCommitted()) { return super.getWriter(); } if (writer != null) { return writer; } if (stream != null) { throw new IllegalStateException("getOutputStream() has already been called!"); } stream = createOutputStream(); writer = new PrintWriter(new OutputStreamWriter(stream, origResponse.getCharacterEncoding())); return writer; }
@SuppressWarnings("deprecation") @Override public void setStatus(int sc, String sm) { super.setStatus(sc, sm); this.statusCode = sc; }
public void sendError(int statusCode, String statusMessage) throws IOException { super.sendError(statusCode, statusMessage); this.status = statusCode; }
@Override public void sendRedirect(String location) throws IOException { super.sendRedirect(location); }
@Override public ServletOutputStream getOutputStream() throws IOException { return super.getOutputStream(); }
/** {@inheritDoc} */ @Override public PrintWriter getWriter() throws IOException { if (writer == null) { if (stream != null) { throw new IllegalStateException( "getOutputStream() has already been called for this response"); } try { getOutputStream(); } catch (final IllegalStateException e) { // issue 488: if a filter has called getWriter() before the MonitoringFilter, we can't call getOutputStream() writer = super.getWriter(); return writer; } final ServletOutputStream outputStream = getOutputStream(); final String charEnc = getHttpServletResponse().getCharacterEncoding(); // HttpServletResponse.getCharacterEncoding() shouldn't return null // according the spec, so feel free to remove that "if" final PrintWriter result; if (charEnc == null) { result = new PrintWriter(outputStream); } else { result = new PrintWriter(new OutputStreamWriter(outputStream, charEnc)); } writer = result; } return writer; }
@Override public void setContentType(String type) { super.setContentType(type); }
/** {@inheritDoc} */ @Override public void reset() { super.reset(); status = 0; stream = null; writer = null; }
/** * Prevents content-length being set if buffering enabled. */ @Override public void setContentLength(final int contentLength) { if (buffer == null) { super.setContentLength(contentLength); } }
@Override public PrintWriter getWriter() throws IOException { return super.getWriter(); }
Iterator writers = ImageIO.getImageWritersByMIMEType(outputType); if (writers.hasNext()) { super.setContentType(outputType); OutputStream out = super.getOutputStream(); try { ImageWriter writer = (ImageWriter) writers.next(); super.setContentType(originalContentType); ServletOutputStream out = super.getOutputStream();
@Override public void setStatus(int sc) { super.setStatus(sc); this.statusCode = sc; }
public void sendError(int statusCode) throws IOException { super.sendError(statusCode); this.status = statusCode; }
@Override public void sendRedirect(String location) throws IOException { copyBodyToResponse(false); super.sendRedirect(location); }
@Override public ServletOutputStream getOutputStream() throws IOException { applyContentType(); return super.getOutputStream(); }