List of usage examples for javax.servlet.http HttpServletResponse setHeader
public void setHeader(String name, String value);
From source file:org.bonitasoft.web.designer.controller.utils.HttpFile.java
/** * Write headers and content in the response *//*from w w w .j a v a2 s .c o m*/ private static void writeFileInResponse(HttpServletResponse response, Path filePath, String mimeType, String contentDispositionType) throws IOException { response.setHeader("Content-Type", mimeType); response.setHeader("Content-Length", String.valueOf(filePath.toFile().length())); response.setHeader("Content-Disposition", new StringBuilder().append(contentDispositionType) .append("; filename=\"").append(filePath.getFileName()).append("\"").toString()); response.setCharacterEncoding(StandardCharsets.UTF_8.toString()); try (OutputStream out = response.getOutputStream()) { Files.copy(filePath, out); } }
From source file:com.handpay.ibenefit.framework.util.WebUtils.java
public static OutputStream buildGzipOutputStream(HttpServletResponse response) throws IOException { response.setHeader("Content-Encoding", "gzip"); response.setHeader("Vary", "Accept-Encoding"); return new GZIPOutputStream(response.getOutputStream()); }
From source file:cn.com.qiqi.order.utils.Servlets.java
/** * Etag Header./*ww w . ja va 2 s. com*/ */ public static void setEtag(HttpServletResponse response, String etag) { response.setHeader(HttpHeaders.ETAG, etag); }
From source file:jp.go.nict.langrid.foundation.servlet.ResponseProcessor.java
private static void addFaultHeader(HttpServletResponse response) { response.setStatus(500);/*www . j av a 2 s . c om*/ response.setContentType("text/xml; charset=utf-8"); response.setHeader("Server", "LanguageGrid-CoreNode/1.0"); response.setDateHeader("Date", new Date().getTime()); }
From source file:com.cnksi.core.web.utils.Servlets.java
/** * Etag Header./*from w w w . j a va2 s. c o m*/ */ public static void setEtag(HttpServletResponse response, String etag) { response.setHeader(HttpHeaders.ETAG, etag); }
From source file:org.myjerry.util.ResponseUtil.java
public static final ModelAndView sendFileToDownload(HttpServletResponse response, String fileToDownload, String fileName, String contentType, boolean isHttp11) throws IOException { response.reset();//w ww .j a v a 2 s .co m setNoCache(response, isHttp11); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); response.setContentType(contentType); ServletOutputStream out; out = response.getOutputStream(); out.print(fileToDownload); out.flush(); out.close(); return null; }
From source file:com.xyz.util.WebUtil.java
/** * Header./*from w w w .j ava 2 s .co m*/ */ public static void setNoCacheHeader(HttpServletResponse response) { //Http 1.0 header response.setDateHeader("Expires", 0); //Http 1.1 header response.setHeader("Cache-Control", "max-age=0"); }
From source file:io.wcm.wcm.commons.caching.CacheHeader.java
/** * Set headers to disallow caching in browser, proxy servers and dispatcher for the current response. * @param response Current response/*from w ww. j a v a 2 s .com*/ */ public static void setNonCachingHeaders(HttpServletResponse response) { response.setHeader(HEADER_PRAGMA, "no-cache"); response.setHeader(HEADER_CACHE_CONTROL, "no-cache"); response.setHeader(HEADER_EXPIRES, "0"); response.setHeader(HEADER_DISPATCHER, "no-cache"); }
From source file:com.liferay.util.servlet.ServletResponseUtil.java
public static void sendFile(HttpServletResponse res, String fileName, byte[] byteArray, String contentType) throws IOException { _log.debug("Sending file of type " + contentType); res.setContentType(contentType);// ww w .j av a 2s .c o m res.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.PUBLIC); res.setHeader(HttpHeaders.PRAGMA, HttpHeaders.PUBLIC); if (Validator.isNotNull(fileName)) { res.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\""); } res.getOutputStream().write(byteArray); res.getOutputStream().flush(); }
From source file:com.eryansky.common.web.utils.WebUtils.java
/** * Header./*from ww w . jav a2 s . c o m*/ */ public static void setNoCacheHeader(HttpServletResponse response) { // Http 1.0 header response.setDateHeader("Expires", 0); // Http 1.1 header response.setHeader("Cache-Control", "no-cache"); }