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.mycompany.login.filter.AutenticacaoFilter.java

@Override
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException failed) throws IOException, ServletException {
    //super.unsuccessfulAuthentication(request, response, failed);
    SecurityContextHolder.clearContext();
    request.removeAttribute("usuarioLogado");
    request.getSession().setAttribute("msg", mensagem);
    request.getSession().invalidate();/* w  ww . j  a v a2 s .  c  o  m*/
    response.sendRedirect("index.xhtml");

}

From source file:com.glweb.web.struts.actions.BaseAction.java

protected void removeFormBean(ActionMapping mapping, HttpServletRequest request) {
    // Remove the obsolete form bean
    if (null != mapping.getAttribute()) {
        if ("request".equals(mapping.getScope())) {
            request.removeAttribute(mapping.getAttribute());
        } else {/* w  w w .  j a va 2s.  c om*/
            HttpSession _session = request.getSession();
            _session.removeAttribute(mapping.getAttribute());
        }
    }
}

From source file:org.jahia.services.render.filter.cache.TemplateNodesCacheKeyPartGenerator.java

@Override
public Object prepareContextForContentGeneration(String value, Resource resource, RenderContext renderContext) {
    HttpServletRequest request = renderContext.getRequest();
    Object original = request.getAttribute("previousTemplate");
    if (!StringUtils.isEmpty(value)) {
        Template template = new Template(value);
        request.setAttribute("previousTemplate", template);
    } else {//www  . j a v a 2 s  .com
        request.removeAttribute("previousTemplate");
    }
    return original;
}

From source file:com.liferay.portal.servlet.SharedServletWrapper.java

public void service(ServletRequest req, ServletResponse res) throws IOException, ServletException {

    if ((_httpServletInstance == null) || (GetterUtil.getBoolean(PropsUtil.get(PropsUtil.TCK_URL)))) {

        _servletInstance.service(req, res);
    } else {/* ww w  .j a v a2s .  c  o m*/
        HttpServletRequest httpReq = (HttpServletRequest) req;

        String sharedSessionId = CookieUtil.get(httpReq.getCookies(), CookieKeys.SHARED_SESSION_ID);

        _log.debug("Shared session id is " + sharedSessionId);

        HttpSession portalSes = null;

        if (sharedSessionId != null) {
            portalSes = SharedSessionPool.get(sharedSessionId);
        }

        HttpSession portletSes = httpReq.getSession();

        if (portalSes == null) {
            portalSes = portletSes;
        } else {
            try {
                portalSes.getCreationTime();
            } catch (IllegalStateException ise) {
                _log.debug("Removing session from pool");

                SharedSessionPool.remove(sharedSessionId);

                portalSes = portletSes;
            }
        }

        HttpServletRequest sharedReq = new SharedServletRequest(httpReq, portalSes);

        sharedReq.setAttribute(WebKeys.SERVLET_CONTEXT_NAME, _servletContextName);

        _httpServletInstance.service(sharedReq, res);

        sharedReq.removeAttribute(WebKeys.SERVLET_CONTEXT_NAME);
    }
}

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

/**
 * *****************************************************************************
 * Actualiza la sentencia.//from  www  .  j  a v  a 2  s.  co  m
 * *****************************************************************************
 * Metodo aun sin desarrollo.
 * *****************************************************************************
 * @param s
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/sentencia/actualizar")
public ModelAndView actualizar(@ModelAttribute Sentencia s, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        return null;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }
}

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

/**
 * *****************************************************************************
 * Obtiene la sentencia.//from ww  w .java  2  s  . c o  m
 * *****************************************************************************
 * Metodo sin desarrollo.
 * *****************************************************************************
 * @param sentenciaID
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/sentencia/obtenerSentencia")
public ModelAndView obtenerSentencia(int sentenciaID, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        return null;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }
}

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

/**
 * *****************************************************************************
 * Obtiene las sentencias por programa./*from  ww  w .  ja v  a2 s  .  c  om*/
 * *****************************************************************************
 * Metodo aun sin desarrollo.
 * *****************************************************************************
 * @param programaID
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/sentencia/obtenerSentenciaPorPrograma")
public ModelAndView obtenerSentenciaPorProgrma(int programaID, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        return null;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }
}

From source file:org.osaf.cosmo.filters.RetryFilter.java

private Exception findFilterException(HttpServletRequest request) {
    Exception e = (Exception) request.getAttribute(ATTR_SERVICE_EXCEPTION);
    if (e == null)
        return null;
    if (isFilterException(e)) {
        // clear for retry
        request.removeAttribute(ATTR_SERVICE_EXCEPTION);
        return e;
    }//from   w w w.ja  v a2s .  c  o  m
    return null;
}

From source file:org.tinygroup.springmvc.coc.impl.AbstractConventionHandlerMethodResolver.java

/**
 * uri??/* w  w w .jav a  2 s.  co  m*/
 */
public Method getHandlerMethod(HttpServletRequest request) {

    String requestUri = getUrlPathHelper().getLookupPathForRequest(request);
    Method mtd = this.getHandlerMethodInternal(request, WebUtil.getUriWithoutExtension(requestUri));
    if (mtd != null) {
        request.removeAttribute(RestfulConventionHandlerMethodResolver.RESTFUL_CONVENTION_VIEW_PATH);
    }
    return mtd;
}

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

/**
 * *****************************************************************************
 * Actualiza los roles.//from   www .  j  a  v a  2s.co m
 * *****************************************************************************
 * Metodo sin desarrollo.
 * *****************************************************************************
 * @param rol
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/rol/actualizar")
public ModelAndView actualizar(@ModelAttribute Rol rol, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        return null;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }
}