List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:org.sakaiproject.jsf.app.SakaiViewHandler.java
public String getActionURL(FacesContext context, String viewId) { HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); if (req.getAttribute(URL_EXT) == null) { // If the request didn't go through JsfTool (the JSF is accessed directly from its webapp, // not as a Sakai tool), then don't do Sakai's special action URL handling. return m_wrapped.getActionURL(context, viewId); }//from ww w . j a v a2s .c o m // get the path that got us here (from the tool's point of view) String path = viewId; // modify the path to remove things that were added by Sakai navigation to get here (prefix path, suffix extension) String prefix = (String) req.getAttribute(URL_PATH); if ((prefix != null) && path.startsWith(prefix)) path = path.substring(prefix.length()); Object extensions = req.getAttribute(URL_EXT); String[] exts = extensions instanceof String ? new String[] { (String) extensions } : (String[]) extensions; for (String ext : exts) { if ((ext != null) && path.endsWith(ext)) path = path.substring(0, path.length() - ext.length()); } // make sure the URL processing uses the Sakai, not Native the request object so we can get at the URL information setup by the invoker req.removeAttribute(Tool.NATIVE_URL); // form our return URL String rv = Web.returnUrl(req, path); // restore (if needed) req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL); M_log.debug("action url for view: " + viewId + " = " + rv); return rv; }
From source file:org.sakaiproject.jsf.app.SakaiViewHandlerWrapper.java
public String getActionURL(FacesContext context, String viewId) { HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); if (req.getAttribute(URL_EXT) == null) { // If the request didn't go through JsfTool (the JSF is accessed directly from its webapp, // not as a Sakai tool), then don't do Sakai's special action URL handling. return getWrapped().getActionURL(context, viewId); }/*from w w w .j a v a 2s. c om*/ // get the path that got us here (from the tool's point of view) String path = viewId; // modify the path to remove things that were added by Sakai navigation to get here (prefix path, suffix extension) String prefix = (String) req.getAttribute(URL_PATH); if ((prefix != null) && path.startsWith(prefix)) path = path.substring(prefix.length()); Object extensions = req.getAttribute(URL_EXT); String[] exts = extensions instanceof String ? new String[] { (String) extensions } : (String[]) extensions; for (String ext : exts) { if ((ext != null) && path.endsWith(ext)) path = path.substring(0, path.length() - ext.length()); } // make sure the URL processing uses the Sakai, not Native the request object so we can get at the URL information setup by the invoker req.removeAttribute(Tool.NATIVE_URL); // form our return URL String rv = Web.returnUrl(req, path); // restore (if needed) req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL); M_log.debug("action url for view: " + viewId + " = " + rv); return rv; }
From source file:org.tinygroup.jspengine.servlet.JspServlet.java
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // START SJSWS 6232180 if (httpMethodsSet != null) { String method = request.getMethod(); if (method == null) { return; }//w ww . j a va 2s. co m boolean isSupportedMethod = httpMethodsSet.contains(method); if (!isSupportedMethod) { if (method.equals("OPTIONS")) { response.addHeader("Allow", httpMethodsString); } else { super.service(request, response); } return; } } // END SJSWS 6232180 String jspUri = null; String jspFile = (String) request.getAttribute(Constants.JSP_FILE); if (jspFile != null) { // JSP is specified via <jsp-file> in <servlet> declaration jspUri = jspFile; request.removeAttribute(Constants.JSP_FILE); } else { /* * Check to see if the requested JSP has been the target of a * RequestDispatcher.include() */ jspUri = (String) request.getAttribute(Constants.INC_SERVLET_PATH); if (jspUri != null) { /* * Requested JSP has been target of RequestDispatcher.include(). * Its path is assembled from the relevant * javax.servlet.include.* request attributes */ String pathInfo = (String) request.getAttribute("javax.servlet.include.path_info"); if (pathInfo != null) { jspUri += pathInfo; } } else { /* * Requested JSP has not been the target of a * RequestDispatcher.include(). Reconstruct its path from the * request's getServletPath() and getPathInfo() */ jspUri = request.getServletPath(); String pathInfo = request.getPathInfo(); if (pathInfo != null) { jspUri += pathInfo; } } } if (log.isDebugEnabled()) { StringBuffer msg = new StringBuffer(); msg.append("JspEngine --> [" + jspUri); msg.append("] ServletPath: [" + request.getServletPath()); msg.append("] PathInfo: [" + request.getPathInfo()); msg.append("] RealPath: [" + context.getRealPath(jspUri)); msg.append("] RequestURI: [" + request.getRequestURI()); msg.append("] QueryString: [" + request.getQueryString()); msg.append("]"); log.debug(msg); } try { boolean precompile = preCompile(request); serviceJspFile(request, response, jspUri, null, precompile); } catch (RuntimeException e) { // STARTS S1AS incrementErrorCount(); // END S1AS throw e; } catch (ServletException e) { // STARTS S1AS incrementErrorCount(); // END S1AS throw e; } catch (IOException e) { // STARTS S1AS incrementErrorCount(); // END S1AS throw e; } catch (Throwable e) { // STARTS S1AS incrementErrorCount(); // END S1AS throw new ServletException(e); } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.frontdesk.web.actions.SaveSessionConfigAction.java
/** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed.//w w w . ja v a 2 s. com * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception Exception if the application business logic throws * an exception */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes and parameters we will need HttpSession session = request.getSession(); DynaValidatorForm sessionForm = (DynaValidatorForm) form; // Validate the transactional control token ActionMessages errors = new ActionMessages(); isTokenValid(request, log.isDebugEnabled()); resetToken(request); if (!isExperimenter(session)) return (mapping.findForward("login_fail")); // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return (mapping.getInputForward()); } SessionBean sessionBean = createSessionBean(session, sessionForm); if (sessionBean == null) { ActionMessages aerrors = new ActionMessages(); aerrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.session.file")); saveErrors(request, aerrors); // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } return (mapping.findForward("failure")); } session.setAttribute("sessionBean", sessionBean); // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } return (mapping.findForward("success")); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.commons.ChooseContextDispatchActionNew.java
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String inputPage = request.getParameter(PresentationConstants.INPUT_PAGE); if (inputPage != null) { request.setAttribute(PresentationConstants.INPUT_PAGE, inputPage); }/*from w w w. ja va2 s . com*/ String nextPage = request.getParameter(PresentationConstants.NEXT_PAGE); if (nextPage != null) { request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage); } setExecutionContext(request); String degreeCurricularPlanId = getFromRequest("degreeCurricularPlanID", request); request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanId); String degreeId = getFromRequest("degreeID", request); request.setAttribute("degreeID", degreeId); // lista List<LabelValueBean> executionPeriodsLabelValueList = buildExecutionPeriodsLabelValueList( degreeCurricularPlanId); if (executionPeriodsLabelValueList.size() > 1) { request.setAttribute("lista", executionPeriodsLabelValueList); } else { request.removeAttribute("lista"); } return mapping.findForward("prepare"); }
From source file:org.jboss.dashboard.ui.panel.PanelDriver.java
/** * Called after panel has been redered//from w w w . j a v a2 s. c o m * * @param panel * @param request */ protected void afterRenderPanel(Panel panel, HttpServletRequest request, HttpServletResponse response) { PanelParameter[] panelParameters = panel.getInstance().getPanelParameters(); for (PanelParameter panelParameter : panelParameters) { request.removeAttribute(panelParameter.getIdParameter()); } PanelSession session = panel.getPanelSession(); session.setAttribute(PARAMETER_ACTION_EXECUTED_ENABLED, Boolean.TRUE); }
From source file:com.glaf.oa.budget.web.springmvc.BudgetController.java
@RequestMapping("/review") public ModelAndView review(HttpServletRequest request, ModelMap modelMap) { User user = RequestUtils.getUser(request); String actorId = user.getActorId(); RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Budget budget = budgetService.getBudget(RequestUtils.getLong(request, "budgetid")); if (budget != null) { request.setAttribute("budget", budget); JSONObject rowJSON = budget.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); // ???/*from w w w . j a v a 2 s .c om*/ String appusername = BaseDataManager.getInstance().getStringValue(budget.getAppuser(), "SYS_USERS"); request.setAttribute("appusername", appusername); // ? // ? List<BaseDataInfo> brandlist = BaseDataManager.getInstance().getDataList("Brand"); BaseDataInfo brand1 = null; BaseDataInfo brand2 = null; for (BaseDataInfo info : brandlist) { if ("1".equals(info.getValue())) { request.setAttribute("brand1", info.getName()); brand1 = info; } else if ("2".equals(info.getValue())) { request.setAttribute("brand2", info.getName()); brand2 = info; } } if (budget != null) { if ("".equals(budget.getBrands1().trim()) && "".equals(budget.getBrands2().trim())) { request.setAttribute("Brands", "MUL"); } else if (!"".equals(budget.getBrands1().trim()) && "".equals(budget.getBrands2().trim())) { request.setAttribute("Brands", brand1.getCode()); } else if (!"".equals(budget.getBrands2().trim()) && "".equals(budget.getBrands1().trim())) { request.setAttribute("Brands", brand2.getCode()); } else if (!"".equals(budget.getBrands2().trim()) && !"".equals(budget.getBrands1().trim())) { request.setAttribute("Brands", "MUL"); } } } else { // ? long deptId01 = user.getDeptId(); SysDepartment curdept = sysDepartmentService.findById(deptId01); // ? String curAreadeptCode = curdept.getCode().substring(0, 2); request.setAttribute("area", curAreadeptCode); budget = new Budget(); budget.setArea(curAreadeptCode); budget.setStatus(-1); budget.setCreateBy(actorId); budget.setAppdate(new Date()); budget.setCreateDate(new Date()); budgetService.save(budget); request.setAttribute("budget", budget); } boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (budget != null) { if (budget.getStatus() == 0 || budget.getStatus() == -1) { canUpdate = true; } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("budget.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/budget/budgetReview", modelMap); }
From source file:com.sinosoft.one.mvc.web.impl.thread.RootEngine.java
/** * Restore the request attributes after an include. * /* w ww . j av a 2s . c om*/ * before the include */ private void restoreRequestAttributesAfterInclude(Invocation inv) { logger.debug("Restoring snapshot of request attributes after include"); HttpServletRequest request = inv.getRequest(); @SuppressWarnings("unchecked") Map<String, Object> attributesSnapshot = (Map<String, Object>) inv .getAttribute("$$one-mvc.attributesBeforeInclude"); // Need to copy into separate Collection here, to avoid side effects // on the Enumeration when removing attributes. Set<String> attrsToCheck = new HashSet<String>(); Enumeration<?> attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); attrsToCheck.add(attrName); } // Iterate over the attributes to check, restoring the original value // or removing the attribute, respectively, if appropriate. for (String attrName : attrsToCheck) { Object attrValue = attributesSnapshot.get(attrName); if (attrValue != null) { if (logger.isDebugEnabled()) { logger.debug("Restoring original value of attribute [" + attrName + "] after include"); } request.setAttribute(attrName, attrValue); } else { if (logger.isDebugEnabled()) { logger.debug("Removing attribute [" + attrName + "] after include"); } request.removeAttribute(attrName); } } }
From source file:org.apache.struts.faces.application.ActionListenerImpl.java
/** * <p>Process the specified <code>ActionEvent</code>.</p> * * @param event The <code>ActionEvent</code> to be processed * * @exception AbortProcessingException to signal that no further * event processing should be performed *//* www . j a va2 s .co m*/ public void processAction(ActionEvent event) throws AbortProcessingException { // If this is an immediate action, or we are NOT nested in a // Struts form, perform the standard processing UIComponent component = event.getComponent(); ActionSource source = (ActionSource) component; boolean standard = source.isImmediate(); if (!standard) { UIComponent parent = component.getParent(); while (parent != null) { if (parent instanceof UIForm) { if (!(parent instanceof FormComponent)) { standard = true; } break; } parent = parent.getParent(); } } if (standard) { if (log.isDebugEnabled()) { log.debug("Performing standard handling for event " + "from source component '" + component.getId() + "'"); } original.processAction(event); return; } // Acquire Servlet API Object References FacesContext context = FacesContext.getCurrentInstance(); ServletContext servletContext = (ServletContext) context.getExternalContext().getContext(); HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); // Log this event if requested if (log.isDebugEnabled()) { log.debug("Performing Struts form submit for event " + " from source component '" + component.getId() + "'"); } // Invoke the appropriate request processor for this request try { request.setAttribute(Constants.ACTION_EVENT_KEY, event); RequestUtils.selectModule(request, servletContext); ModuleConfig moduleConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY); if (log.isTraceEnabled()) { log.trace("Assigned to module with prefix '" + moduleConfig.getPrefix() + "'"); } RequestProcessor processor = getRequestProcessor(moduleConfig, servletContext); if (log.isTraceEnabled()) { log.trace("Invoking request processor instance " + processor); } processor.process(request, response); context.responseComplete(); } catch (Exception e) { log.error("Exception processing action event " + event, e); } finally { request.removeAttribute(Constants.ACTION_EVENT_KEY); } }
From source file:com.glaf.oa.budget.web.springmvc.BudgetController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { User user = RequestUtils.getUser(request); String actorId = user.getActorId(); RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Budget budget = budgetService.getBudget(RequestUtils.getLong(request, "budgetid")); List<BaseDataInfo> brandlist = BaseDataManager.getInstance().getDataList("Brand"); BaseDataInfo brand1 = null;/*w w w.j a v a 2 s.c om*/ BaseDataInfo brand2 = null; for (BaseDataInfo info : brandlist) { if ("1".equals(info.getValue())) { request.setAttribute("brand1", info.getName()); brand1 = info; } else if ("2".equals(info.getValue())) { request.setAttribute("brand2", info.getName()); brand2 = info; } } if (budget != null) { request.setAttribute("budget", budget); JSONObject rowJSON = budget.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); // ??? String appusername = BaseDataManager.getInstance().getStringValue(budget.getAppuser(), "SYS_USERS"); request.setAttribute("appusername", appusername); // ? // ? if (budget != null) { if ("".equals(budget.getBrands1().trim()) && "".equals(budget.getBrands2().trim())) { request.setAttribute("Brands", "MUL"); } else if (!"".equals(budget.getBrands1().trim()) && "".equals(budget.getBrands2().trim())) { request.setAttribute("Brands", brand1.getCode()); } else if (!"".equals(budget.getBrands2().trim()) && "".equals(budget.getBrands1().trim())) { request.setAttribute("Brands", brand2.getCode()); } else if (!"".equals(budget.getBrands2().trim()) && !"".equals(budget.getBrands1().trim())) { request.setAttribute("Brands", "MUL"); } } } else { // ? budget = new Budget(); long deptId01 = user.getDeptId(); SysDepartment curdept = sysDepartmentService.findById(deptId01); // ? String curAreadeptCode = curdept.getCode().substring(0, 2); request.setAttribute("area", curAreadeptCode); budget = new Budget(); budget.setArea(curAreadeptCode); budget.setStatus(-1); budget.setDept(curdept.getCode()); budget.setAppuser(user.getActorId()); budget.setPost(RequestUtil.getLoginUser(request).getHeadship()); budget.setCreateBy(actorId); budget.setAppdate(new Date()); budget.setCreateDate(new Date()); budgetService.save(budget); request.setAttribute("budget", budget); JSONObject rowJSON = budget.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); } boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (budget != null) { if (budget.getStatus() == 0 || budget.getStatus() == -1) { canUpdate = true; } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("budget.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/budget/budgetedit", modelMap); }