List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:org.ihtsdo.otf.refset.interceptor.RequestProcessingTimeInterceptor.java
@Override public void postHandle(HttpServletRequest req, HttpServletResponse res, Object arg2, ModelAndView model) throws Exception { if (isEnabled) { String tTime = Long.toString((System.currentTimeMillis() - (Long) req.getAttribute(START_TIME)) / 1000); LOGGER.debug("Total time taken in this request is {}", tTime); res.addHeader(TOTAL_TIME, tTime); }/* w w w.j a v a 2 s . c o m*/ }
From source file:istata.web.HtmlController.java
@RequestMapping("/est") public void est(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); stataService.saveCmd(path);//from ww w . jav a2 s .c om File f = stataService.est(); InputStream in = new FileInputStream(f); IOUtils.copy(in, response.getOutputStream()); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.department.ReadTeacherProfessorshipsByExecutionYearAction.java
private void prepareForm(DynaActionForm dynaForm, HttpServletRequest request) { InfoExecutionYear infoExecutionYear = (InfoExecutionYear) request.getAttribute("executionYear"); InfoTeacher infoTeacher = (InfoTeacher) request.getAttribute("infoTeacher"); dynaForm.set("externalId", infoTeacher.getExternalId()); dynaForm.set("teacherId", infoTeacher.getExternalId().toString()); if (dynaForm.get("executionYearId") == null) { dynaForm.set("executionYearId", infoExecutionYear.getExternalId()); }//from w w w . j a v a2s . c o m List detailedProfessorshipList = (List) request.getAttribute("detailedProfessorshipList"); List executionCourseIds = new ArrayList(); Map hours = new HashMap(); for (int i = 0; i < detailedProfessorshipList.size(); i++) { DetailedProfessorship dps = (DetailedProfessorship) detailedProfessorshipList.get(i); String executionCourseId = dps.getInfoProfessorship().getInfoExecutionCourse().getExternalId(); if (dps.getResponsibleFor().booleanValue()) { executionCourseIds.add(executionCourseId); } if (dps.getMasterDegreeOnly().booleanValue()) { if (dps.getInfoProfessorship().getHours() != null) { hours.put(executionCourseId.toString(), dps.getInfoProfessorship().getHours().toString()); } } } dynaForm.set("executionCourseResponsability", executionCourseIds.toArray(new String[] {})); dynaForm.set("hours", hours); }
From source file:com.github.cherimojava.orchidae.controller.LayoutController.java
/** * Serves page layouts. Anything which ends with html is supposed to be a layout and will be handled through this * method//from ww w. ja v a 2s . co m */ @RequestMapping(value = "/**/{page}.html", method = GET) public String layout(@PathVariable("page") String page, HttpSession session, HttpServletRequest request, ModelMap map) { if (formPages.contains(page)) { // For form pages we have to add the csrf token map.addAttribute("_csrf", request.getAttribute(CsrfToken.class.getName())); } if (UPLOAD_PAGE.equals(page)) { // provide some batch uuid, which will later be used to group all those pictures uploaded in a batch map.addAttribute("batch", UUID.randomUUID().toString()); } return "layout/" + page; }
From source file:de.chludwig.websec.saml2sp.controller.Saml2SPErrorController.java
@RequestMapping(ERROR_PAGE_PATH) public ModelAndView errorPage(HttpServletRequest request, HttpServletResponse response, @CurrentUser ApplicationUser currentUser) { ModelAndView modelAndView = Saml2SpController.createModelAndView("error", currentUser); modelAndView.addObject("forwardedFrom", request.getAttribute("javax.servlet.forward.request_uri")); modelAndView.addObject("statusCode", response.getStatus()); return modelAndView; }
From source file:ltistarter.controllers.TsugiController.java
@RequestMapping({ "", "/" }) public String home(HttpServletRequest req, Principal principal, Model model) { commonModelPopulate(req, principal, model); model.addAttribute("name", "lti1p"); req.getSession().setAttribute("login", "oauth"); LTIRequest ltiRequest = (LTIRequest) req.getAttribute(LTIRequest.class.getName()); if (ltiRequest != null) { model.addAttribute("lti", true); model.addAttribute("ltiContext", ltiRequest.getLtiContextId()); model.addAttribute("ltiUser", ltiRequest.getLtiUserDisplayName()); model.addAttribute("ltiLink", ltiRequest.getLtiLinkId()); }/*from w w w .j a v a2 s . c om*/ return "tsugi"; // name of the template }
From source file:org.zaizi.sensefy.auth.LoginConfig.java
private Filter csrfHeaderFilter() { return new OncePerRequestFilter() { @Override/* w w w. j a v a2s . co m*/ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (csrf != null) { Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); String token = csrf.getToken(); if (cookie == null || token != null && !token.equals(cookie.getValue())) { cookie = new Cookie("XSRF-TOKEN", token); cookie.setPath("/"); response.addCookie(cookie); // response.setHeader("Access-Control-Allow-Origin", // "*"); // response.setHeader("Access-Control-Allow-Methods", // "POST, GET, OPTIONS, DELETE"); // response.setHeader("Access-Control-Max-Age", // "3600"); // response.setHeader("Access-Control-Allow-Headers", // "x-requested-with"); } } filterChain.doFilter(request, response); } }; }
From source file:com.adito.policyframework.actions.PrincipalInformationAction.java
/** * @param mapping//from w w w .j a v a 2s .co m * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward principalInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PrincipalInformationForm informationForm = (PrincipalInformationForm) form; Principal principal = (Principal) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE); informationForm.initialise(principal); return mapping.findForward("display"); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.department.ReadTeacherProfessorshipsByExecutionYearAction.java
protected InfoTeacher getInfoTeacher(HttpServletRequest request, DynaActionForm dynaForm) throws Exception { InfoTeacher infoTeacher = (InfoTeacher) request.getAttribute("infoTeacher"); if (infoTeacher == null) { final User userView = Authenticate.getUser(); infoTeacher = (InfoTeacher) ReadTeacherByOID.runReadTeacherByOID(dynaForm.get("externalId").toString()); request.setAttribute("infoTeacher", infoTeacher); }//from ww w. j a va 2 s . c o m return infoTeacher; }
From source file:istata.web.HtmlController.java
@RequestMapping(value = { "/graph **", "/graph **/**" }) public void graphs(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("image/png"); String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); stataService.saveCmd(path);/* ww w.ja v a 2s. c om*/ path = path.substring(7); stataService.run("graph display " + path); File f = stataService.graph(path); InputStream in = new FileInputStream(f); IOUtils.copy(in, response.getOutputStream()); }