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.opencnc.controllers.ElementoGraficoController.java

/**
 * *****************************************************************************
 * Obtiene el elemento grafico por modelo.
 * *****************************************************************************
 * Metodo sin desarrollo.//w ww  . j a  va2  s . c  o  m
 * *****************************************************************************
 * @param ModeloID
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */

@RequestMapping("/elemento/obtenerElementoPorModelo")
public ModelAndView obtenerElementoPorModelo(int ModeloID, 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.hihsoft.baseclass.web.controller.BaseController.java

/**
 * requestsession//from w w w.j  a  va 2s  . c  om
 * 
 * @param request
 * @param key
 * @author Xiaojf
 * @since 2011-6-29
 */
public void remove(HttpServletRequest request, String key) {
    request.removeAttribute(key);
    request.getSession().removeAttribute(key);
}

From source file:net.swas.explorer.servlet.ms.GetMSConfig.java

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 *///  w  w w  .  j  a  v  a2 s. c  o  m
@SuppressWarnings("unchecked")
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    JSONObject messageJson = new JSONObject();

    messageJson.put("action", "readMSConfig");
    this.prod.send(messageJson.toJSONString());

    String revMsg = this.cons.getReceivedMessage(request.getServletContext());
    log.info("Received Message :" + revMsg);
    if (revMsg != null) {

        JSONParser parser = new JSONParser();
        JSONObject revJson = null;
        try {

            revJson = (JSONObject) parser.parse(revMsg);
            request.removeAttribute("msConfig");
            request.setAttribute("msConfig", revJson);

        } catch (ParseException e) {

            e.printStackTrace();

        }

    }

    RequestDispatcher rd = request.getRequestDispatcher("/msConfigForm.jsp");
    rd.forward(request, response);

}

From source file:org.jahia.services.render.filter.AggregateFilter.java

@Override
public void finalize(RenderContext renderContext, Resource resource, RenderChain renderChain) {

    if (skipAggregation(renderContext.getRequest())) {
        return;//w ww  . ja  v a2  s . co m
    }

    HttpServletRequest request = renderContext.getRequest();

    // no keys stack, no aggregation, nothing to clean
    if (request.getAttribute(FRAGMENT_KEYS_STACK) == null) {
        return;
    }

    // we are finalizing on a main resource, remove keys stack
    if (Resource.CONFIGURATION_PAGE.equals(resource.getContextConfiguration())) {
        request.removeAttribute(FRAGMENT_KEYS_STACK);
    }

    // we are finalizing on a sub fragment aggregation, pop the key from the stack
    @SuppressWarnings("unchecked")
    Map<String, Object> moduleMap = (Map<String, Object>) request.getAttribute("moduleMap");
    if (moduleMap.get(AGGREGATING) == Boolean.TRUE) {
        @SuppressWarnings("unchecked")
        Stack<String> keysStack = (Stack<String>) request.getAttribute(FRAGMENT_KEYS_STACK);
        keysStack.pop();
    }
}

From source file:cn.webwheel.ActionSetter.java

@SuppressWarnings("unchecked")
public void clear(HttpServletRequest request) {
    Map<String, Object> map = (Map<String, Object>) request.getAttribute(WRPName);
    if (map != null) {
        for (Object o : map.values()) {
            if (o instanceof FileEx[]) {
                for (FileEx fileEx : (FileEx[]) o) {
                    fileEx.destroy();//w  ww .  jav  a2 s  .  com
                }
            }
        }
        request.removeAttribute(WRPName);
    }
}

From source file:org.springframework.boot.actuate.autoconfigure.MetricsFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws ServletException, IOException {
    StopWatch stopWatch = createStopWatchIfNecessary(request);
    String path = new UrlPathHelper().getPathWithinApplication(request);
    int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
    try {//from  ww w  .jav a 2  s  .  c o m
        chain.doFilter(request, response);
        status = getStatus(response);
    } finally {
        if (!request.isAsyncStarted()) {
            stopWatch.stop();
            request.removeAttribute(ATTRIBUTE_STOP_WATCH);
            recordMetrics(request, path, status, stopWatch.getTotalTimeMillis());
        }
    }
}

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

/**
 * *****************************************************************************
 * Edita la informacion de los modelos.//from w w w  .  ja v a2s .com
 * *****************************************************************************
 * Metodo sin terminar.
 * *****************************************************************************
 * @param id
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
//@RequestMapping(value = "/modelo/editarModelo/{id}", method = RequestMethod.GET)
@RequestMapping("modelo/editarModelo/{id}")
public ModelAndView editarModelo(@PathVariable Integer id, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    HttpSession sess = request.getSession();
    if (sess != null) {
        Session s = HibernateUtil.getSessionFactory().openSession();

        //Modelo u = (Modelo)s.get(Modelo.class, 2);
        Modelo u = (Modelo) s.get(Modelo.class, id);

        ModelAndView m = new ModelAndView("/modelo/editarModelo");
        m.addObject("modelo", u);

        return m;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }

}

From source file:net.sourceforge.fenixedu.presentationTier.Action.resourceAllocationManager.ManageShiftDA.java

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

    ContextUtils.setClassContext(request);

    InfoClass infoClass = (InfoClass) request.getAttribute(PresentationConstants.CLASS_VIEW);
    InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT);

    RemoverTurno.run(infoShift, infoClass);

    ContextUtils.setShiftContext(request);
    request.removeAttribute(PresentationConstants.CLASS_VIEW);

    return prepareEditShift(mapping, form, request, response);
}

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

/**
 * *****************************************************************************
 * Guarda Rol/*  www.  j  av  a 2  s  .com*/
 * *****************************************************************************
 * @param rol
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/rol/guardarRol")
public ModelAndView guardarRol(@ModelAttribute Rol rol, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {

        Calendar c = new GregorianCalendar();
        Date d1 = c.getTime();

        rol.setCreadoFecha(d1);
        Session s = HibernateUtil.getSessionFactory().openSession();

        Transaction t = s.getTransaction();
        s.beginTransaction();
        s.saveOrUpdate(rol);
        t.commit();

        return lista(request, response);
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }

}

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

/**
 * *****************************************************************************
 * Crea la lista de programas de los usuarios.
 * *****************************************************************************
 * @param request/* w  w  w .  j ava2 s.c  o m*/
 * @param response
 * @return
 * @throws Exception 
 */
@RequestMapping("/programa/lista")
public ModelAndView lista(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession sess = request.getSession();
    if (sess != null) {
        Session s = HibernateUtil.getSessionFactory().openSession();
        Usuario us = (Usuario) sess.getAttribute("usuario");
        Criteria c = s.createCriteria(Programa.class);
        //c.add(Restrictions.eq("modelo", us));
        List<Programa> l = c.list();

        ModelAndView m = new ModelAndView("/programa/lista");
        m.addObject("programas", l);

        return m;
    } else {
        request.removeAttribute("usuario");
        return new ModelAndView("redirect:/usuario/login.htm");
    }

}