List of usage examples for javax.servlet.http HttpServletRequest setAttribute
public void setAttribute(String name, Object o);
From source file:com.adito.core.actions.AbstractMultiFormDispatchAction.java
private static SubActionWrapper getSubActionWrapper(ActionMapping mapping, ActionForm form, ActionMapping subMapping, HttpServletRequest request, int index) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException { String formName = subMapping.getName(); ActionForm subForm = getActionForm(subMapping, request); FormBeanConfig formBean = mapping.getModuleConfig().findFormBeanConfig(formName); String className = formBean == null ? null : formBean.getType(); if (className == null) return null; if (subForm == null || !className.equals(subForm.getClass().getName())) subForm = (ActionForm) Class.forName(className).newInstance(); if ("request".equals(mapping.getScope())) request.setAttribute(formName, subForm); else// ww w.jav a 2s.com request.getSession().setAttribute(formName, subForm); subForm.reset(mapping, request); /* * We dont want to try and populate all forms on a post, only the one * that has requested it. For this the form must have a hidden parameter * with the name of 'subForm' and the value being the form name to * populate */ AbstractMultiFormDispatchForm dispatchForm = (AbstractMultiFormDispatchForm) form; if (formName.equals(dispatchForm.getSubForm())) { dispatchForm.setSelectedTab(dispatchForm.getTabName(index)); BeanUtils.populate(subForm, request.getParameterMap()); } return new SubActionWrapper(subForm, subMapping); }
From source file:gov.va.vinci.chartreview.util.CRSchemaXML.java
/** * Parses the give CRSchemaXML (read from the POST Body of the Request) * * @param request an HttpServletRequest//from w w w . jav a 2 s . co m * @return a groovy.util.XmlSlurper * @throws ConverterException */ public static Object parse(HttpServletRequest request) throws ConverterException { Object xml = request.getAttribute(CACHED_XML); if (xml != null) return xml; String encoding = request.getCharacterEncoding(); if (encoding == null) { encoding = Converter.DEFAULT_REQUEST_ENCODING; } try { if (!request.getMethod().equalsIgnoreCase("GET")) { xml = parse(request.getInputStream(), encoding); request.setAttribute(CACHED_XML, xml); } return xml; } catch (IOException e) { throw new ConverterException("Error parsing CRSchemaXML", e); } }
From source file:com.swiftcorp.portal.common.util.WebUtils.java
public static void setSuccessMessages(HttpServletRequest request, String[] messageKeys, String[][] messageArgValues) { if (messageKeys == null || messageKeys.length == 0) { theLogger.error("messageKeys cant null or empty"); throw new RuntimeException("messageKeys cant null or empty"); }//from w ww. j a va2 s . co m ActionMessages actionMessages = new ActionMessages(); int index = 0; for (String messageKey : messageKeys) { String[] value = null; if (messageArgValues != null && messageArgValues.length >= index) { value = messageArgValues[index]; } ActionMessage actionMessage = new ActionMessage(messageKey, value); actionMessages.add(ActionMessages.GLOBAL_MESSAGE, actionMessage); index++; } request.setAttribute(Globals.MESSAGE_KEY, actionMessages); }
From source file:com.stratelia.silverpeas.pdcPeas.servlets.PdcSearchRequestRouterHelper.java
/** * Get user choices from the PdcSearchSessionController and put it in the HTTP request. Prepare * data that will be used in the result view. * * @param request//from w w w . jav a 2 s . co m * @param pdcSC * @throws Exception */ public static void setUserChoices(HttpServletRequest request, PdcSearchSessionController pdcSC) throws Exception { QueryParameters queryParameters = pdcSC.getQueryParameters(); if (queryParameters != null) { String authorSearch = queryParameters.getCreatorId(); // travail sur l'auteur if (authorSearch != null) { UserDetail userDetail = pdcSC.getOrganisationController().getUserDetail(authorSearch); queryParameters.setCreatorDetail(userDetail); } request.setAttribute("QueryParameters", queryParameters); } request.setAttribute("DisplayParamChoices", pdcSC.getDisplayParamChoices()); request.setAttribute("ChoiceNbResToDisplay", pdcSC.getListChoiceNbResToDisplay()); request.setAttribute("NbResToDisplay", Integer.valueOf(pdcSC.getNbResToDisplay())); request.setAttribute("SortValue", Integer.valueOf(pdcSC.getSortValue())); request.setAttribute("SortOrder", pdcSC.getSortOrder()); request.setAttribute("ItemType", pdcSC.getDataType()); // List of user favorite requests List<InterestCenter> favoriteRequests = buildICentersList(pdcSC); String requestSelected = request.getParameter("iCenterId"); request.setAttribute("RequestList", favoriteRequests); if (requestSelected != null) { request.setAttribute("RequestSelected", requestSelected); } String showAllAxis = request.getParameter("showNotOnlyPertinentAxisAndValues"); if ("true".equals(showAllAxis)) { pdcSC.setShowOnlyPertinentAxisAndValues(false); request.setAttribute("showAllAxis", "true"); } else { pdcSC.setShowOnlyPertinentAxisAndValues(true); } request.setAttribute("synonyms", pdcSC.getSynonyms()); // put search type request.setAttribute("SearchType", Integer.valueOf(pdcSC.getSearchType())); }
From source file:com.aoindustries.website.signup.SignupCustomizeManagementActionHelper.java
public static void setConfirmationRequestAttributes(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, SignupSelectPackageForm signupSelectPackageForm, SignupCustomizeServerForm signupCustomizeServerForm, SignupCustomizeManagementForm signupCustomizeManagementForm) throws IOException, SQLException { // Lookup things needed by the view AOServConnector rootConn = SiteSettings.getInstance(servletContext).getRootAOServConnector(); PackageDefinition packageDefinition = rootConn.getPackageDefinitions() .get(signupSelectPackageForm.getPackageDefinition()); // Store as request attribute for the view request.setAttribute("totalMonthlyRate", getTotalMonthlyRate(rootConn, signupCustomizeServerForm, signupCustomizeManagementForm, packageDefinition)); request.setAttribute("backupOnsiteOption", getBackupOnsiteOption(rootConn, signupCustomizeManagementForm)); request.setAttribute("backupOffsiteOption", getBackupOffsiteOption(rootConn, signupCustomizeManagementForm)); request.setAttribute("backupDvdOption", getBackupDvdOption(rootConn, signupCustomizeManagementForm)); request.setAttribute("distributionScanOption", getDistributionScanOption(rootConn, signupCustomizeManagementForm)); request.setAttribute("failoverOption", getFailoverOption(rootConn, signupCustomizeManagementForm)); }
From source file:org.apache.ofbiz.passport.event.LinkedInEvents.java
private static String checkLoginLinkedInUser(HttpServletRequest request, Document userInfo, String accessToken) {/* www . j a v a 2 s.c o m*/ Delegator delegator = (Delegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); String productStoreId = ProductStoreWorker.getProductStoreId(request); String linkedInUserId = LinkedInAuthenticator.getLinkedInUserId(userInfo); GenericValue linkedInUser = null; try { linkedInUser = delegator.findOne("LinkedInUser", UtilMisc.toMap("linkedInUserId", linkedInUserId), false); } catch (GenericEntityException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } if (linkedInUser != null) { boolean dataChanged = false; if (!accessToken.equals(linkedInUser.getString("accessToken"))) { linkedInUser.set("accessToken", accessToken); dataChanged = true; } if (!envPrefix.equals(linkedInUser.getString("envPrefix"))) { linkedInUser.set("envPrefix", envPrefix); dataChanged = true; } if (!productStoreId.equals(linkedInUser.getString("productStoreId"))) { linkedInUser.set("productStoreId", productStoreId); dataChanged = true; } if (dataChanged) { try { linkedInUser.store(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); } } } else { linkedInUser = delegator.makeValue("LinkedInUser", UtilMisc.toMap("accessToken", accessToken, "productStoreId", productStoreId, "envPrefix", envPrefix, "linkedInUserId", linkedInUserId)); try { linkedInUser.create(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); } } try { GenericValue userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", linkedInUserId), null, false)); LinkedInAuthenticator authn = new LinkedInAuthenticator(); authn.initialize(dispatcher); if (UtilValidate.isEmpty(userLogin)) { String userLoginId = authn.createUser(userInfo); userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); } String autoPassword = RandomStringUtils.randomAlphanumeric( EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue()); boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt")); userLogin.set("currentPassword", useEncryption ? HashCrypt.digestHash(LoginServices.getHashType(), null, autoPassword) : autoPassword); userLogin.store(); request.setAttribute("USERNAME", userLogin.getString("userLoginId")); request.setAttribute("PASSWORD", autoPassword); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } catch (AuthenticatorException e) { Debug.logError(e.getMessage(), module); request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } return "success"; }
From source file:org.netxilia.server.rest.html.GenericHTMLProviderInterceptor.java
@Override public void intercept(ModelAndView<Object> modelAndView, HttpServletRequest request) { request.setAttribute("images", request.getContextPath() + "/images"); request.setAttribute("css", request.getContextPath() + "/css"); request.setAttribute("scripts", request.getContextPath() + "/js"); request.setAttribute(USER, userService.getCurrentUser()); }
From source file:com.swiftcorp.portal.common.util.WebUtils.java
public static void setSuccessMessages(HttpServletRequest request, String[] messageKeys, String messageArgValues) { if (messageKeys == null || messageKeys.length == 0) { theLogger.error("messageKeys cant null or empty"); throw new RuntimeException("messageKeys cant null or empty"); }//from www. j av a 2 s . c o m ActionMessages actionMessages = new ActionMessages(); int index = 0; for (String messageKey : messageKeys) { String value = null; theLogger.error("setSuccessMessages(): " + messageArgValues + "added"); value = messageArgValues; theLogger.error("setSuccessMessages(): " + value + "added"); ActionMessage actionMessage = new ActionMessage(messageKey, value); actionMessages.add(ActionMessages.GLOBAL_MESSAGE, actionMessage); index++; } request.setAttribute(Globals.MESSAGE_KEY, actionMessages); }
From source file:cz.muni.fi.dndtroopsweb.controllers.BasicController.java
/** * just for testing purposes//www . j a v a 2s . c o m * @param request * @param response * @return */ @RequestMapping(value = "/logout", method = RequestMethod.GET) public String logoutPage(HttpServletRequest request, HttpServletResponse response) { request.setAttribute("authenticatedUser", null); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return "home"; }
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;// w w w. j a v a 2 s . c o m }