Example usage for javax.servlet.http HttpServletRequest removeAttribute

List of usage examples for javax.servlet.http HttpServletRequest removeAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest removeAttribute.

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes an attribute from this request.

Usage

From source file:com.sinosoft.one.mvc.web.RequestPath.java

public RequestPath(HttpServletRequest request) {
    // method/* w  ww.  ja va2  s  . c  o m*/
    setMethod(parseMethod(request));

    // ctxpath
    setCtxpath(request.getContextPath());
    String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath
    // dispather, uri, ctxpath
    String uri;
    if (WebUtils.isIncludeRequest(request)) {
        setDispatcher(Dispatcher.INCLUDE);
        uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
        invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE));
        setMvcPath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE));
    } else {
        if (request.getAttribute(MvcConstants.WINDOW_REQUEST_URI) != null) {
            uri = (String) request.getAttribute(MvcConstants.WINDOW_REQUEST_URI);
            request.removeAttribute(MvcConstants.WINDOW_REQUEST_URI);
            request.setAttribute(MvcConstants.IS_WINDOW_REQUEST, "1");
        } else {
            uri = request.getRequestURI();
            request.removeAttribute(MvcConstants.IS_WINDOW_REQUEST);
        }

        this.setMvcPath(request.getServletPath());
        if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) {
            this.setDispatcher(Dispatcher.REQUEST);
        } else {
            this.setDispatcher(Dispatcher.FORWARD);
        }
    }
    if (uri.startsWith("http://") || uri.startsWith("https://")) {
        int start = uri.indexOf('/', 9);
        if (start == -1) {
            uri = "";
        } else {
            uri = uri.substring(start);
        }
    }
    if (uri.indexOf('%') != -1) {
        try {
            String encoding = request.getCharacterEncoding();
            if (encoding == null || encoding.length() == 0) {
                encoding = "UTF-8";
            }
            uri = URLDecoder.decode(uri, encoding);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    this.setUri(uri);
    // requestPathctxpathincludeinvocationCtxpath

    if (getCtxpath().length() <= 1) {
        setMvcPath(getUri());
    } else {
        setMvcPath(getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length()));
    }
}

From source file:com.glaf.oa.seal.web.springmvc.SealController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    Seal seal = sealService.getSeal(RequestUtils.getLong(request, "sealid"));
    if (seal != null) {
        request.setAttribute("seal", seal);
        JSONObject rowJSON = seal.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    } else {/*from w w w  . j a va 2s. com*/
        seal = new Seal();
        long deptId01 = user.getDeptId();
        SysDepartment curdept = sysDepartmentService.findById(deptId01);
        // ?
        String curAreadeptCode = curdept.getCode().substring(0, 2);

        seal.setArea(curAreadeptCode);
        seal.setDept(curdept.getCode());
        seal.setAppuser(user.getActorId());
        seal.setPost(RequestUtil.getLoginUser(request).getHeadship());
        request.setAttribute("seal", seal);
        JSONObject rowJSON = seal.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 (seal != null) {
            if (seal.getStatus() == 0 || seal.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("seal.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }
    if (seal != null) {
        String appusername = BaseDataManager.getInstance().getStringValue(seal.getAppuser(), "SYS_USERS");
        request.setAttribute("appusername", appusername);
    }

    return new ModelAndView("/oa/seal/sealedit", modelMap);
}

From source file:org.zkoss.zkgrails.ZKGrailsPageFilter.java

protected void applyDecorator(Page page, Decorator decorator, HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    final String uriPath = decorator.getURIPath();
    if (uriPath != null && uriPath.endsWith(".gsp")) {
        request.setAttribute(PAGE, page);

        detectContentTypeFromPage(page, response);

        RequestDispatcher rd = request.getRequestDispatcher(decorator.getURIPath());
        if (!response.isCommitted()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Rendering layout using forward: " + decorator.getURIPath());
            }/*from   www .j av  a  2s  .c  o m*/
            rd.forward(request, response);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Rendering layout using include: " + decorator.getURIPath());
            }
            request.setAttribute(GrailsApplicationAttributes.GSP_TO_RENDER, decorator.getURIPath());
            rd.include(request, response);
            request.removeAttribute(GrailsApplicationAttributes.GSP_TO_RENDER);
        }

        // set the headers specified as decorator init params
        while (decorator.getInitParameterNames().hasNext()) {
            String initParam = (String) decorator.getInitParameterNames().next();
            if (initParam.startsWith("header.")) {
                response.setHeader(initParam.substring(initParam.indexOf('.')),
                        decorator.getInitParameter(initParam));
            }
        }
        request.removeAttribute(PAGE);
    } else {

        super.applyDecorator(page, decorator, request, response);

    }
}

From source file:com.glaf.oa.payment.web.springmvc.PaymentController.java

@RequestMapping("/review")
public ModelAndView review(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Payment payment = paymentService.getPayment(RequestUtils.getLong(request, "paymentid"));
    if (payment != null) {
        // ???//from w w w .j  ava 2 s .co m
        String appusername = BaseDataManager.getInstance().getStringValue(payment.getAppuser(), "SYS_USERS");
        request.setAttribute("appusername", appusername);
        request.setAttribute("payment", payment);
        JSONObject rowJSON = payment.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }

    if (RequestUtils.getBoolean(request, "lookover")) {
        request.setAttribute("lookover", true);
    } else {
        request.setAttribute("lookover", false);
    }
    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (payment != null) {
            if (payment.getStatus() == 0 || payment.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("payment.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/payment/payment_review", modelMap);
}

From source file:org.apereo.portal.layout.StylesheetUserPreferencesServiceImpl.java

private void clearStylesheetUserPreferencesCache(HttpServletRequest request,
        StylesheetPreferencesKey stylesheetPreferencesKey) {
    final String key = getCacheKey(stylesheetPreferencesKey);

    request.removeAttribute(key);

    final HttpSession session = request.getSession();
    session.removeAttribute(key);//  ww  w. j a  v a  2 s .c  o  m
}

From source file:jp.terasoluna.fw.web.struts.action.RequestProcessorEx.java

/**
 * StrutsANVtH?[NGXgp??[^f??g?B//from ww  w . j a v  a2 s .c o m
 *
 * <p>rWlX?WbN?sfANVtH?[
 * ????A
 * RequestProcessorprocessPopulate()?\bhN?B</p>
 * <p>struts-config.xmlANV}bsO??A
 * cancelPopulatetrue ???A
 * processPopulate LZ?B</p>
 *
 * @param req HTTPNGXg
 * @param res HTTPX|X
 * @param form ANVtH?[
 * @param mapping ANV}bsO
 * @throws ServletException T?[ubgO
 */
@Override
protected void processPopulate(HttpServletRequest req, HttpServletResponse res, ActionForm form,
        ActionMapping mapping) throws ServletException {

    if (log.isDebugEnabled()) {
        log.debug("processPopulate() called. path = " + mapping.getPath());
    }

    boolean cancelPopulateflg = false;
    cancelPopulateflg = ((ActionMappingEx) mapping).getCancelPopulate();
    if (cancelPopulateflg) {
        if (log.isDebugEnabled()) {
            log.debug("processPopulate() canceled.");
        }
        // ?~?s
        return;
    }

    String skipPopulate = (String) req.getAttribute(SKIP_POPULATE);
    if (skipPopulate != null) {
        if (skipPopulate.equals(mapping.getName())) {

            if (log.isDebugEnabled()) {
                log.debug("processPopulate() skipped.");
            }
            // ?~?s
            return;
        }
        req.removeAttribute(SKIP_POPULATE);
    }
    // X?[p?[NX processPopulate() ?s
    super.processPopulate(req, res, form, mapping);

}

From source file:com.glaf.oa.salescontract.web.springmvc.SalescontractController.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");
    Salescontract salescontract = salescontractService.getSalescontract(RequestUtils.getLong(request, "id"));
    if (salescontract != null) {
        request.setAttribute("salescontract", salescontract);
        JSONObject rowJSON = salescontract.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
        // ???/*  w  w w .  java  2s  .c  o  m*/
        String appusername = BaseDataManager.getInstance().getStringValue(salescontract.getAppuser(),
                "SYS_USERS");
        request.setAttribute("appusername", appusername);

    } else {
        // ? 
        long deptId01 = user.getDeptId();
        SysDepartment curdept = sysDepartmentService.findById(deptId01);
        // ?
        String curAreadeptCode = curdept.getCode().substring(0, 2);
        request.setAttribute("area", curAreadeptCode);
        salescontract = new Salescontract();
        salescontract.setArea(curAreadeptCode);
        salescontract.setDept(curdept.getCode());
        salescontract.setAppuser(user.getActorId());
        salescontract.setHeadship(RequestUtil.getLoginUser(request).getHeadship());
        salescontract.setOptionalsum(0.00);

        salescontract.setStatus(-1);
        salescontract.setCreateBy(actorId);
        salescontract.setAppdate(new Date());
        salescontract.setCreatedate(new Date());
        salescontractService.save(salescontract);
        request.setAttribute("salescontract", salescontract);
        JSONObject rowJSON = salescontract.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 (salescontract != null) {
            if (salescontract.getStatus() == 0 || salescontract.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("salescontract.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/salesContract/salesContractedit", modelMap);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ChooseExamsMapContextDANew.java

public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String degreeId = getFromRequest("degreeID", request);
    request.setAttribute("degreeID", degreeId);
    Degree degree = FenixFramework.getDomainObject(degreeId);
    if (degree != null) {
        OldCmsSemanticURLHandler.selectSite(request, degree.getSite());
    }//from w w w  .  ja v a  2s. c om
    request.setAttribute("degree", degree);

    String executionDegreeId = getFromRequest("executionDegreeID", request);
    request.setAttribute("executionDegreeID", executionDegreeId);

    String degreeCurricularPlanId = getFromRequest("degreeCurricularPlanID", request);
    request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanId);

    List<LabelValueBean> executionPeriodsLabelValueList = buildExecutionPeriodsLabelValueList(
            degreeCurricularPlanId);
    if (executionPeriodsLabelValueList.size() > 1) {
        request.setAttribute("lista", executionPeriodsLabelValueList);
    } else {
        request.removeAttribute("lista");
    }

    Boolean inEnglish = getFromRequestBoolean("inEnglish", request);
    if (inEnglish == null) {
        inEnglish = getLocale(request).getLanguage().equals(Locale.ENGLISH.getLanguage());
    }
    request.setAttribute("inEnglish", inEnglish);

    request.removeAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD);

    return mapping.findForward("prepare");
}

From source file:com.glaf.oa.payment.web.springmvc.PaymentController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Payment payment = paymentService.getPayment(RequestUtils.getLong(request, "paymentid"));
    if (payment != null) {
        // ???//from   w  ww.j a  v  a2s . co m
        String appusername = BaseDataManager.getInstance().getStringValue(payment.getAppuser(), "SYS_USERS");
        request.setAttribute("appusername", appusername);
        request.setAttribute("payment", payment);
        JSONObject rowJSON = payment.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    } else {
        payment = new Payment();
        long deptId01 = user.getDeptId();
        SysDepartment curdept = sysDepartmentService.findById(deptId01);
        // ?
        String curAreadeptCode = curdept.getCode().substring(0, 2);

        payment.setArea(curAreadeptCode);
        payment.setDept(curdept.getCode());
        payment.setAppuser(user.getActorId());
        payment.setPost(RequestUtil.getLoginUser(request).getHeadship());
        request.setAttribute("payment", payment);
        JSONObject rowJSON = payment.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 (payment != null) {
            if (payment.getStatus() == 0 || payment.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("payment.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/payment/payment_edit", modelMap);
}

From source file:com.opencnc.controllers.ModeloController.java

/**
 * *****************************************************************************
 * Abre la lista de modelos por usuario.
 * *****************************************************************************
 * @param request//  w  w w  .  jav  a  2s.co  m
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping(value = "/modelo/abrir")
public ModelAndView abrir(/*@RequestParam Integer usuarioId,*/
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    HttpSession sess = request.getSession();
    if (sess != null) {
        //String sid = session.getId();

        Session s = HibernateUtil.getSessionFactory().openSession();
        //Usuario us = (Usuario)s.get(Usuario.class, usuarioId);

        Usuario us = (Usuario) sess.getAttribute("usuario");

        Integer luser = us.getUsuarioId();

        Criteria c = s.createCriteria(Modelo.class);
        c.add(Restrictions.eq("usuario", us));
        //Es una mala practica para cambiarlo referirse a borrarModelo
        c.add(Restrictions.eq("creadoPor", 0));// justo filtra para no borrar los modelos

        //c.add(Restrictions.eq("creadoPor", 3));
        List<Modelo> lm = c.list();

        ModelAndView m = new ModelAndView("/modelo/abrir");
        m.addObject("modelos", lm);
        m.addObject("nombreUsuario", us.getNombre());
        return m;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }

}