List of usage examples for javax.servlet.http HttpServletResponse setDateHeader
public void setDateHeader(String name, long date);
From source file:com.dangdang.ddframe.job.security.WwwAuthFilter.java
private void needAuthenticate(final HttpServletResponse response) { response.setStatus(401);/*from w w w .j a v a2 s. c om*/ response.setHeader("Cache-Control", "no-store"); response.setDateHeader("Expires", 0); response.setHeader("WWW-authenticate", AUTH_PREFIX + "Realm=\"Elastic Job Console Auth\""); }
From source file:com.lcw.one.common.servlet.ValidateCodeServlet.java
private void createImage(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/jpeg"); /*/* w ww. j a v a 2s . c om*/ * ?? */ String width = request.getParameter("width"); String height = request.getParameter("height"); if (StringUtils.isNumeric(width) && StringUtils.isNumeric(height)) { w = NumberUtils.toInt(width); h = NumberUtils.toInt(height); } BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); }
From source file:com.founder.fix.fixflow.explorer.util.ResultUtils.java
/** * ?Header./*from w ww. j av a 2 s. co m*/ */ public void setDisableCacheHeader(HttpServletResponse response) { // Http 1.0 header response.setDateHeader("Expires", 1L); response.addHeader("Pragma", "no-cache"); // Http 1.1 header response.setHeader("Cache-Control", "no-cache, no-store, max-age=0"); }
From source file:org.olat.core.gui.media.ServletUtil.java
public static void setJSONResourceHeaders(HttpServletResponse response) { // we ignore the accept-charset from the request and always write in utf-8 // -> see comment below //response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=utf-8"); // never allow to cache pages since they contain a timestamp valid only once // HTTP 1.1//from ww w . jav a 2 s . co m response.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, proxy-revalidate, s-maxage=0, max-age=0"); // HTTP 1.0 response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); }
From source file:org.openxdata.server.servlet.FormOpenServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); response.setHeader("Cache-Control", "no-store"); response.setContentType(OpenXDataConstants.HTTP_HEADER_CONTENT_TYPE_XML); response.getOutputStream().print((String) request.getSession().getAttribute(KEY_FILE_CONTENTS)); }
From source file:org.openxdata.server.servlet.ImportServlet.java
private void writeErrorsToResponse(String errors, HttpServletResponse response) throws IOException { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); response.setHeader("Cache-Control", "no-store"); response.setHeader("Content-Type", "text/csv;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=importErrros.csv"); response.getWriter().write(errors);/* ww w . j a v a2 s . c om*/ }
From source file:com.dangdang.ddframe.job.console.security.WwwAuthFilter.java
private void authenticateSuccess(final HttpServletResponse response) { response.setStatus(200);//from www . ja v a 2 s . c o m response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-store"); response.setDateHeader("Expires", 0); }
From source file:org.openxdata.server.servlet.ReportServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); response.setHeader("Cache-Control", "no-store"); String format = request.getParameter("format"); response.setContentType(format.equalsIgnoreCase("pdf") ? OpenXDataConstants.HTTP_HEADER_CONTENT_TYPE_PDF : OpenXDataConstants.HTTP_HEADER_CONTENT_TYPE_TEXT_HTML); String fileName = request.getParameter("name"); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); Integer reportId = Integer.parseInt(request.getParameter("reportId")); response.getOutputStream()//from www.ja va2 s .c o m .write(reportService.getReportDataBytes(request.getRequestURI(), reportId, format)); }
From source file:gov.nih.nci.ncicb.tcga.dcc.common.web.StaticContentServlet.java
/** * Set HTTP headers to allow caching for the given number of seconds. * @param seconds number of seconds into the future that the response should be cacheable for *///from w w w . ja v a 2s. c om private void configureCaching(HttpServletResponse response, int seconds) { // HTTP 1.0 header response.setDateHeader(HTTP_EXPIRES_HEADER, System.currentTimeMillis() + seconds * 1000L); // HTTP 1.1 header response.setHeader(HTTP_CACHE_CONTROL_HEADER, "max-age=" + seconds); }
From source file:com.xhsoft.framework.common.filter.SessionUpcFilter.java
public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = ((HttpServletRequest) req); HttpSession session = (request).getSession(); //UserInfo user=(UserInfo)session.getAttribute(SessionCons.CURRENT_ACCOUNT); try {/* w ww . j av a 2 s . com*/ /*if(user!=null){ LoginUtil.setLoginUser(request, user); }*/ HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.setHeader("Pragma", "No-cache"); httpResponse.setHeader("Cache-Control", "no-cache"); httpResponse.setDateHeader("Expires", 0); chain.doFilter(request, response); } catch (IOException ex) { logger.error(request.getRemoteAddr() + " io error : " + ex); } catch (Exception de) { de.printStackTrace(); } logger.debug("User Filter end!"); }