List of usage examples for javax.servlet.http HttpServletResponse addHeader
public void addHeader(String name, String value);
From source file:org.smigo.config.RequestLogFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse resp = (HttpServletResponse) response; HttpServletRequest req = (HttpServletRequest) request; resp.addHeader("SmigoUser", req.getRemoteUser()); log.info("Incoming request:" + req.getMethod() + req.getRequestURL().toString()); request.setAttribute(REQUEST_TIMER, System.nanoTime()); chain.doFilter(request, response);//from www .ja v a 2 s . com logHandler.log(req, resp); }
From source file:scratch.cucumber.example.security.servlet.XAuthTokenHttpServletRequestBinder.java
@Override public void add(HttpServletResponse response, String username) { final String token = tokenFactory.create(username); response.addHeader(X_AUTH_TOKEN, token); response.addCookie(new Cookie(X_AUTH_TOKEN, token)); }
From source file:com.qcadoo.report.internal.controller.ReportController.java
private void disableCache(final HttpServletResponse response) { response.addHeader("Expires", "Tue, 03 Jul 2001 06:00:00 GMT"); response.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"); response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.addHeader("Pragma", "no-cache"); }
From source file:me.doshou.admin.maintain.push.web.controller.PushController.java
/** * ?????// w ww . j a va 2 s .c o m * @return */ @RequestMapping(value = "/admin/polling") @ResponseBody public Object polling(HttpServletResponse resp, @CurrentUser User user) { resp.setHeader("Connection", "Keep-Alive"); resp.addHeader("Cache-Control", "private"); resp.addHeader("Pragma", "no-cache"); Long userId = user.getId(); if (userId == null) { return null; } //? ? if (!pushService.isOnline(userId)) { Long unreadMessageCount = messageApi.countUnread(userId); List<Map<String, Object>> notifications = notificationApi.topFiveNotification(user.getId()); Map<String, Object> data = Maps.newHashMap(); data.put("unreadMessageCount", unreadMessageCount); data.put("notifications", notifications); pushService.online(userId); return data; } else { // return pushService.newDeferredResult(userId); } }
From source file:com.example.multipart.MultipartServiceImpl.java
@Override public void downloadByteArrayData(byte[] content, String contentType, String filename, HttpServletResponse response) throws IOException { InputStream is = new ByteArrayInputStream(content); response.setContentType(contentType); response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=\"" + filename + "\""); copy(is, response.getOutputStream()); response.flushBuffer();/*from ww w . ja v a 2 s . c om*/ }
From source file:org.openmrs.module.casereport.CrossOriginResourceSharingFilter.java
/** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) *//* w w w. j a v a2 s .c o m*/ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (log.isDebugEnabled()) { log.debug("In Cors filter..."); } HttpServletRequest request = (HttpServletRequest) servletRequest; String gpValue = Context.getAdministrationService() .getGlobalProperty(CaseReportWebConstants.GP_ENABLE_CORS); if (Boolean.valueOf(gpValue)) { if (log.isDebugEnabled()) { log.debug("Cors is enabled"); } HttpServletResponse response = (HttpServletResponse) servletResponse; response.addHeader("Access-Control-Allow-Origin", "*"); response.addHeader("Access-Control-Allow-Methods", "GET, POST"); response.addHeader("Access-Control-Allow-Headers", "Authorization, Content-Type"); response.addHeader("Access-Control-Max-Age", "3600"); //TODO add GP to disable this filter if (request.getMethod().equals("OPTIONS")) { if (log.isDebugEnabled()) { log.debug("Cors filter responding with Ok status"); } response.setStatus(HttpServletResponse.SC_OK); return; } } else { if (log.isDebugEnabled()) { log.debug("Cors is disabled"); } } // pass the request along the filter chain chain.doFilter(request, servletResponse); }
From source file:org.atlasapi.application.SourceRequestsController.java
@RequestMapping(value = "/4/requests/{rid}/approve", method = RequestMethod.POST) public void storeSourceRequest(HttpServletRequest request, HttpServletResponse response, @PathVariable String rid) throws IOException { response.addHeader("Access-Control-Allow-Origin", "*"); try {/* w ww.ja v a 2s .co m*/ Id requestId = Id.valueOf(idCodec.decode(rid)); sourceRequestManager.approveSourceRequest(requestId, userFetcher.userFor(request).get()); } catch (Exception e) { ErrorSummary summary = ErrorSummary.forException(e); new ErrorResultWriter().write(summary, null, request, response); } }
From source file:alpine.filters.ClickjackingFilter.java
@Override public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException { final HttpServletResponse response = (HttpServletResponse) res; chain.doFilter(req, response);//from ww w. j a va 2s. c o m response.addHeader("X-Frame-Options", mode); }
From source file:nl.mineleni.cbsviewer.servlet.GZIPHttpServletResponseWrapper.java
/** * Instantiates a new GZIP http servlet response wrapper. * * @param response//from w w w . j a v a2 s. c om * the response * @throws IOException * Signals that an I/O exception has occurred. */ public GZIPHttpServletResponseWrapper(HttpServletResponse response) throws IOException { super(response); response.addHeader(HttpHeaders.CONTENT_ENCODING, "gzip"); }
From source file:de.thm.arsnova.web.DeprecatedApiInterceptorHandler.java
@Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception { if (getDeprecatedApiAnnotation(handler) != null) { response.addHeader("X-Deprecated-Api", "1"); }/* w w w. ja va 2 s . c o m*/ return super.preHandle(request, response, handler); }