List of usage examples for javax.servlet.http HttpServletResponse setDateHeader
public void setDateHeader(String name, long date);
From source file:com.zoe.weiya.security.WwwAuthFilter.java
private void needAuthenticate(final HttpServletRequest request, final HttpServletResponse response) { response.setStatus(401);/*from ww w . j a va2 s. co m*/ response.setHeader("Cache-Control", "no-store"); response.setDateHeader("Expires", 0); response.setHeader("WWW-authenticate", AUTH_PREFIX + "Realm=\"WeiYa Auth\""); }
From source file:cn.shengyuan.yun.admin.system.controller.CommonController.java
@RequestMapping(value = "/captchaImage", method = RequestMethod.GET) public String captchaImage(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setDateHeader("Expires", 0); // Set standard HTTP/1.1 no-cache headers. response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // Set IE extended HTTP/1.1 no-cache headers (use addHeader). response.addHeader("Cache-Control", "post-check=0, pre-check=0"); // Set standard HTTP/1.0 no-cache header. response.setHeader("Pragma", "no-cache"); // return a jpeg response.setContentType("image/jpeg"); // create the text for the image String capText = captchaProducer.createText(); // store the text in the session request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText); // create the image with the text BufferedImage bi = captchaProducer.createImage(capText); ServletOutputStream out = response.getOutputStream(); // write the data out ImageIO.write(bi, "jpg", out); try {//from w w w .ja v a 2 s.co m out.flush(); } finally { out.close(); } return null; }
From source file:com.dangdang.ddframe.job.console.security.WwwAuthFilter.java
private void needAuthenticate(final HttpServletRequest request, final HttpServletResponse response) { response.setStatus(401);//from w ww.j ava 2 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:org.rhq.enterprise.gui.legacy.util.RequestUtils.java
/** * When you really really want to defeat a browser's cache, expire the content and set the no-cache header * * @param expire set <i>true</i> to have the content expire immediately *//* w w w . j av a 2s.co m*/ public static void bustaCache(ServletRequest request, ServletResponse response, boolean expire) { if (!(response instanceof HttpServletResponse)) { return; } HttpServletResponse res = (HttpServletResponse) response; if (request.getProtocol().equalsIgnoreCase("HTTP/1.0")) { res.setHeader("Pragma", "no-cache"); } else if (request.getProtocol().equalsIgnoreCase("HTTP/1.1")) { res.setHeader("Cache-Control", "no-cache"); } if (expire) { Date now = new Date(); res.setDateHeader("Date", now.getTime()); res.setDateHeader("Expires", now.getTime() + 1000); } }
From source file:org.apache.struts.chain.servlet.RequestNoCache.java
protected void requestNoCache(Context context) { ServletWebContext swcontext = (ServletWebContext) context; HttpServletResponse response = swcontext.getResponse(); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); }
From source file:net.gplatform.sudoor.server.captcha.model.CaptchaEngine.java
public void renderCapcha(HttpServletRequest request, HttpServletResponse response) throws Exception { // Set to expire far in the past. response.setDateHeader("Expires", 0); // Set standard HTTP/1.1 no-cache headers. response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // Set IE extended HTTP/1.1 no-cache headers (use addHeader). response.addHeader("Cache-Control", "post-check=0, pre-check=0"); // Set standard HTTP/1.0 no-cache header. response.setHeader("Pragma", "no-cache"); // return a jpeg response.setContentType("image/jpeg"); // create the text for the image String capText = captchaProducer.createText(); // store the text in the session request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText); logger.debug("Save Captcha: {} in Session:{}", capText, request.getSession().getId()); // create the image with the text BufferedImage bi = captchaProducer.createImage(capText); ServletOutputStream out = response.getOutputStream(); // write the data out ImageIO.write(bi, "jpg", out); try {/* w w w .ja va 2 s .c o m*/ out.flush(); } finally { out.close(); } }
From source file:edu.wisc.web.util.NoCacheHeaderFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate"); response.setDateHeader("Expires", 0); filterChain.doFilter(request, response); }
From source file:org.openmrs.module.logmanager.web.view.DocumentXmlView.java
@SuppressWarnings("rawtypes") @Override/*from w ww.j av a2 s . c om*/ protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Disable caching response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); // Get document and filename from model Document document = (Document) model.get(sourceKey); String filename = (String) model.get(filenameKey); if (document != null) { // Set response headers response.setContentType("text/xml"); if (filename != null) response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); // Write document XML to response stream LogManagerUtils.writeDocument(document, response.getWriter()); } else response.getWriter().write("ERROR: Document is null"); }
From source file:org.openxdata.designer.server.FileOpenServlet.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("text/xml; charset=utf-8"); response.getOutputStream().print((String) request.getSession().getAttribute(KEY_FILE_CONTENTS)); }
From source file:org.zht.framework.filter.jcaptcha.JCaptchaFilter.java
/** * ???./* w w w . ja v a 2s. c o m*/ */ protected void genernateCaptchaImage(final HttpServletRequest request, final HttpServletResponse response) throws IOException { response.setDateHeader("Expires", 0); response.addHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setContentType("image/jpeg"); ServletOutputStream out = response.getOutputStream(); try { String captchaId = request.getSession(true).getId(); BufferedImage challenge = (BufferedImage) captchaService.getChallengeForID(captchaId, request.getLocale()); ImageIO.write(challenge, "jpg", out); out.flush(); } catch (CaptchaServiceException e) { logger.error(e.getMessage(), e); } finally { out.close(); } }