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:actions.EditStudent.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward findForward = mapping.findForward("main"); StudentForm formStudent = (StudentForm) request.getAttribute("studentForm"); System.out.println("This is where the functionality to edit a student will be."); return findForward; }
From source file:com.antelink.sourcesquare.server.servlet.FeedbackServlet.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) { logger.debug("publishing results"); try {//from w ww . j av a 2s . c om String name = (String) request.getAttribute("feedback-name"); String mail = (String) request.getAttribute("feedback-email"); String message = (String) request.getAttribute("feedback-message"); response.setContentType("text/html;charset=utf-8"); this.publishUrl = this.server.feedback(new Feedback(name, mail, message)); response.getWriter().append(URLEncoder.encode(this.publishUrl, "UTF-8")); } catch (IOException e) { logger.error("error publishing results to the server", e); } }
From source file:com.vportal.portlet.vcmsviewcontent.action.RSSAction.java
protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); long plid = ParamUtil.getLong(request, "p_l_id"); long companyId = ParamUtil.getLong(request, "companyId"); long groupId = ParamUtil.getLong(request, "groupId"); String categoryId = ParamUtil.getString(request, "categoryId", "0"); String portletSelectId = ParamUtil.getString(request, "portletSelectId", "0"); long organizationId = ParamUtil.getLong(request, "organizationId"); int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.DEFAULT_TYPE); double version = ParamUtil.getDouble(request, "version", RSSUtil.DEFAULT_VERSION); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT); String feedURL = themeDisplay.getURLPortal() + themeDisplay.getPathMain() + "/vcmsviewcontent/view?"; String entryURL = feedURL;/*w w w . j av a2 s . c om*/ String rss = StringPool.BLANK; if (layout != null) { groupId = layout.getGroupId(); PortletURL rssURL = PortletURLFactoryUtil.create(request, portletSelectId, plid, PortletRequest.RENDER_PHASE); rssURL.setParameter("struts_action", "/vcmsviewcontent/view"); rssURL.setParameter("categoryId", categoryId); rssURL.setParameter("cat_parent", categoryId); feedURL = rssURL.toString(); entryURL = feedURL; rss = VcmsCategoryServiceUtil.getCategoriesByRSS(categoryId, 5, type, version, displayStyle, entryURL, entryURL, 5, themeDisplay); } return rss.getBytes(StringPool.UTF8); }
From source file:org.surfnet.oaaas.resource.AbstractResource.java
public Response validateScope(HttpServletRequest request, List<String> requiredScopes) { VerifyTokenResponse verifyTokenResponse = (VerifyTokenResponse) request .getAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE); List<String> grantedScopes = verifyTokenResponse.getScopes(); for (String requiredScope : requiredScopes) { if (!grantedScopes.contains(requiredScope)) { LOG.debug("Resource required scopes ({}) which the client has not been granted ({})", requiredScopes, grantedScopes); return Response.status(HttpServletResponse.SC_BAD_REQUEST) .entity(new ErrorResponse(OAuth2Validator.ValidationResponse.SCOPE_NOT_VALID.getValue(), OAuth2Validator.ValidationResponse.SCOPE_NOT_VALID.getDescription())) .build();// w w w. j a va2 s . c om } } return null; }
From source file:cn.edu.zjnu.acm.judge.config.JudgeHandlerInterceptor.java
@ModelAttribute public void addAttributes(HttpServletRequest request, @RequestParam(value = "url", required = false) String url, Authentication authentication) { if (Boolean.TRUE.equals(request.getAttribute(APPLIED_ONCE_KEY))) { return;/*from w ww .j av a 2s. co m*/ } request.setAttribute(APPLIED_ONCE_KEY, true); if (!StringUtils.isEmptyOrWhitespace(url)) { request.setAttribute(BACK_URL_ATTRIBUTE_NAME, url); } else { String uri = getString(RequestDispatcher.FORWARD_SERVLET_PATH, HttpServletRequest::getServletPath, request); String query = getString(RequestDispatcher.FORWARD_QUERY_STRING, HttpServletRequest::getQueryString, request); if (query != null) { uri = uri + '?' + query; } request.setAttribute(BACK_URL_ATTRIBUTE_NAME, uri); } Optional.ofNullable(authentication).map(Authentication::getName).map(mailMapper::getMailInfo) .ifPresent(mailInfo -> request.setAttribute("mailInfo", mailInfo)); }
From source file:org.dawnsci.marketplace.controllers.ExtendedRestApiController.java
/** * Used by the client software to obtain a CSRF token to use in further * communication with the server./*from w w w . j a v a 2s. c o m*/ */ @ResponseBody @RequestMapping(value = "/token") public ResponseEntity<String> login(HttpServletRequest request) { CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); HttpHeaders headers = new HttpHeaders(); headers.add(token.getHeaderName(), token.getToken()); return new ResponseEntity<>("you got your token", headers, HttpStatus.OK); }
From source file:net.cloudkit.enterprises.infrastructure.commons.ExecuteTimeInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { Long startTime = (Long) request.getAttribute(START_TIME); if (startTime == null) { startTime = Long.valueOf(System.currentTimeMillis()); request.setAttribute(START_TIME, startTime); }//from ww w . j av a2 s . c o m return true; }
From source file:org.dawnsci.marketplace.controllers.PageController.java
@RequestMapping(value = { "/pages/*.md" }, method = RequestMethod.GET) public String markdown(HttpServletRequest request, ModelMap map, Principal principal) { addCommonItems(map, principal);/*from w w w . jav a 2s .c o m*/ String resource = ((String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .substring(1); Path path = fileService.getPageFile(resource).toPath(); map.addAttribute("text", parse(path)); return "page"; }
From source file:architecture.ee.web.servlet.ViewRendererServlet.java
protected Map resolveModel(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) { Map map = (Map) httpservletrequest.getAttribute(WebApplicatioinConstants.MODEL_ATTRIBUTE); if (map != null) return map; else/*from www . j a va2 s . c om*/ return Collections.EMPTY_MAP; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerComponentGenerator.java
private String getHead(String templateName, Map<String, Object> root, HttpServletRequest request) { // The Freemarker head template displays the page title in the <title> tag. Get the value out of the request. String title = (String) request.getAttribute("title"); if (!StringUtils.isEmpty(title)) { root.put("title", title); }/*from w w w .jav a 2s .c o m*/ return get(templateName, root, request); }