List of usage examples for javax.servlet.http HttpServletResponse setHeader
public void setHeader(String name, String value);
From source file:org.jasig.cas.web.flow.AbstractLogoutAction.java
/** * Prevent caching by adding the appropriate headers. * Copied from the <code>preventCaching</code> method in the {@link WebContentGenerator} class. * * @param response the HTTP response.// w w w .ja v a 2s . c o m */ protected final void preventCaching(final HttpServletResponse response) { response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 1L); response.setHeader("Cache-Control", "no-cache"); response.addHeader("Cache-Control", "no-store"); }
From source file:com.mejmo.appletraus.server.controller.JnlpController.java
@RequestMapping(value = "/Applet.jnlp") public String downloadJNLPFile(@RequestParam(value = "cookie", required = true) String cookie, @RequestParam(value = "sessionId", required = true) String sessionId, HttpServletResponse response, Model model) {/*from w w w. j ava2 s . c om*/ response.setHeader("Content-Type", "application/x-java-jnlp-file"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); model.addAttribute("cookie", cookie); model.addAttribute("sessionId", sessionId); return "jnlp"; }
From source file:com.ewcms.component.checkcode.web.ImageCaptchaServlet.java
private void initResponseHeader(final HttpServletResponse response) { response.setHeader("Content-Language", "zh-CN"); response.setHeader("Cache-Control", "no-store"); //set on cache ///Http 1.0 header response.setDateHeader("Expires", 0); response.addHeader("Pragma", "no-cache"); //Http 1.1 header response.setHeader("Cache-Control", "no-cache"); response.setContentType(IMG_JPEG_TYPE); }
From source file:de.codecentric.boot.admin.web.EndpointCorsInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { response.setHeader("Access-Control-Allow-Origin", origin); response.setHeader("Access-Control-Allow-Headers", headers); return super.preHandle(request, response, handler); }
From source file:tomekkup.helenos.security.web.authentication.AbstractJsonAuthenticationHandler.java
protected final void writeResult(HttpServletResponse response, Authentication authentication) throws IOException { response.setHeader("Content-Type", "application/json"); PrintWriter writer = response.getWriter(); objectMapper.writeValue(writer, (authentication != null ? authentication.getAuthorities() : null)); writer.flush();/* w ww.j av a 2s . c o m*/ }
From source file:authentication.ResponseHeaderAuthenticationListener.java
/** {@inheritDoc} */ @Override//from www . j a v a2s . c o m public void onAuthenticationSuccess(final AuthenticationEvent event) throws IOException { final JWTClaimsSet claimsSet = new JWTClaimsSet(); final long now = System.currentTimeMillis(); claimsSet.setSubject(event.getUsername()); claimsSet.setIssueTime(new Date(now)); claimsSet.setIssuer("http://localhost:8080/snackbar/"); claimsSet.setExpirationTime(new Date(now + FIVE_HOURS_IN_MILLISECONDS)); claimsSet.setNotBeforeTime(new Date(now)); final SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet); try { signedJWT.sign(signer); } catch (final JOSEException e) { throw new AuthenticationServiceException("The given JWT could not be signed."); } final HttpServletResponse resp = event.getResponse(); resp.setHeader("Authorization", String.format("Bearer %s", signedJWT.serialize())); }
From source file:org.shredzone.cilla.view.interceptor.GenericViewInterceptor.java
@Override public String onRendering(String template, HttpServletRequest req, HttpServletResponse resp) { req.setAttribute("selfUri", req.getRequestURI()); resp.setHeader("Vary", "Accept-Language"); return null;/*from www. j a v a2s. c o m*/ }
From source file:com.thinkberg.moxo.dav.GetHandler.java
void setHeader(HttpServletResponse response, FileContent content) throws FileSystemException { response.setHeader("Last-Modified", Util.getDateString(content.getLastModifiedTime())); response.setHeader("Content-Type", content.getContentInfo().getContentType()); }
From source file:com.ewcms.component.citizen.web.servlate.JavaScriptServlet.java
private void initResponseHeader(final HttpServletResponse response, final String encoding) { response.setHeader("Content-Language", "zh-CN"); String fullContentType = JS_TYPE + ";charset=" + encoding; response.setContentType(fullContentType); }
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)); }