Example usage for javax.servlet.http HttpSession getAttribute

List of usage examples for javax.servlet.http HttpSession getAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Usage

From source file:mx.com.quadrum.contratos.controller.crud.ContactoController.java

@ResponseBody
@RequestMapping(value = "eliminarContacto", method = RequestMethod.POST)
public String eliminarContacto(Contacto contacto, BindingResult bindingResult, HttpSession session) {
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }/*from   w ww. ja  v a2 s  .c o m*/
    return contactoService.eliminar(contacto);
}

From source file:pivotal.au.se.gemfirexdweb.controller.RefreshController.java

@RequestMapping(value = "/refresh", method = RequestMethod.GET)
public String showTables(Model model, HttpServletResponse response, HttpServletRequest request,
        HttpSession session) throws Exception {

    if (session.getAttribute("user_key") == null) {
        logger.debug("user_key is null new Login required");
        response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
        return null;
    } else {// w w w .ja va2 s  .  c o m
        Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key"));
        if (conn == null) {
            response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
            return null;
        } else {
            if (conn.isClosed()) {
                response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
                return null;
            }
        }

    }

    logger.debug("Received request refresh schema object list");

    Map schemaMap = (Map) session.getAttribute("schemaMap");
    Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key"));

    // get schema count now
    schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap, (String) session.getAttribute("schema"));

    session.setAttribute("schemaMap", schemaMap);

    // This will resolve to /WEB-INF/jsp/tables.jsp
    return "main";
}

From source file:psiprobe.controllers.jsp.DisplayJspController.java

@Override
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    boolean compile = ServletRequestUtils.getBooleanParameter(request, "compile", false);

    HttpSession session = request.getSession(false);
    Summary summary = (Summary) session.getAttribute(SUMMARY_ATTRIBUTE);
    if (summary == null || !contextName.equals(summary.getName())) {
        summary = new Summary();
        summary.setName(contextName);//from w ww  . j a v a 2  s .c o  m
    }
    getContainerWrapper().getTomcatContainer().listContextJsps(context, summary, compile);

    session.setAttribute(SUMMARY_ATTRIBUTE, summary);

    if (compile) {
        return new ModelAndView(new RedirectView(
                request.getRequestURI() + "?webapp=" + (contextName.length() == 0 ? "/" : contextName)));
    }
    return new ModelAndView(getViewName(), "summary", summary);
}

From source file:me.ineson.demo.app.MainController.java

/**
 * @param model//  w w  w .  j a va  2  s.  co  m
 * @return
 */
@RequestMapping(value = "/logout")
public @ResponseBody String logout(HttpSession session) {
    log.info("User " + session.getAttribute(SecurityContext.ATTRIBUTE_NAME) + " is logging out");
    session.invalidate();
    return StringUtils.EMPTY;
}

From source file:com.igame.app.controller.CouponController.java

@RequestMapping(value = "/list", method = RequestMethod.POST)
@ResponseBody/*  w ww  .jav  a2  s . c o m*/
public JSONObject getCoupon(HttpSession session) {
    long appid = ((SecUser) session.getAttribute("user")).getAppid();
    log.debug("CouponController --> CouponEntity appid:{}", appid);
    List<CouponEntity> goods = couponService.getCoupon(appid);

    JSONObject object = new JSONObject(2);
    if (goods != null && !goods.isEmpty()) {
        object.put("total", goods.size());
    }
    object.put("rows", goods);
    return object;
}

From source file:de.berlios.jhelpdesk.web.preferences.filter.CustomFilterController.java

@RequestMapping(value = "/preferences/filters/{filterId}/delete.html", method = RequestMethod.GET)
public String deleteFilter(@PathVariable("filterId") Long filterId, ModelMap map, HttpSession session) {
    User currentUser = (User) session.getAttribute("user");
    TicketFilter filter = ticketFilterDAO.getById(filterId);
    if (filter != null && filter.isOwnedBy(currentUser)) {
        try {//w w w . j a  v a  2  s .c om
            ticketFilterDAO.delete(filter);
            session.setAttribute("user", userDAO.getById(currentUser.getUserId()));
            map.addAttribute("message", null);
        } catch (DAOException ex) {
            throw new RuntimeException(ex);
        }
    }
    map.addAttribute("filters", ticketFilterDAO.getAllFiltersForUser(currentUser));
    return "preferences/filters/showAll";
}

From source file:mx.com.quadrum.contratos.controller.busquedas.ContratoBusquedaAdminController.java

@RequestMapping(value = "buscarPorTipoDeContratoAdmin/{idTipoContrato}", method = RequestMethod.GET)
public ModelAndView buscarPorTipoDeContratoAdmin(@PathVariable("idTipoContrato") Integer idTipoContrato,
        ModelMap model, HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }/*from  ww w  .j  av  a 2s.c  o  m*/
    List<Contrato> contratos = busquedasContratos.buscarPorTipoDeContrato((idTipoContrato));
    model.put("contratos", contratos);
    return new ModelAndView("crud/contratoAux", model);
}

From source file:mx.com.quadrum.contratos.controller.busquedas.ContratoBusquedaAdminController.java

@RequestMapping(value = "buscarPorContactoAdmin/{nombre}/{paterno}", method = RequestMethod.GET)
public ModelAndView buscarPorContactoAdmin(@PathVariable("nombre") String nombre,
        @PathVariable("paterno") String paterno, ModelMap model, HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }/*w ww.j  a  v a 2 s . c o m*/
    List<Contrato> contratos = busquedasContratos.buscarPorContacto(nombre, paterno);
    model.put("contratos", contratos);
    return new ModelAndView("crud/contratoAux", model);
}

From source file:mx.com.quadrum.contratos.controller.busquedas.ContratoBusquedaAdminController.java

@RequestMapping(value = "buscarPorContactoAdmin/{nombre}", method = RequestMethod.GET)
public ModelAndView buscarPorContactoAdmin(@PathVariable("nombre") String nombre, ModelMap model,
        HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }/*from   ww  w. ja  va  2  s. co m*/
    List<Contrato> contratos = busquedasContratos.buscarPorContacto(nombre);
    model.put("contratos", contratos);
    return new ModelAndView("crud/contratoAux", model);
}

From source file:mx.com.quadrum.contratos.controller.busquedas.ContratoBusquedaAdminController.java

@RequestMapping(value = "buscarPorEmpleadoAdmin/{idEmpleado}", method = RequestMethod.GET)
public ModelAndView buscarPorEmpleadoAdmin(@PathVariable("idEmpleado") Integer idEmpleado, ModelMap model,
        HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }/*  w w  w.  j a  v a 2s.c o m*/
    List<Contrato> contratos = busquedasContratos.buscarPorEmpleado(idEmpleado);
    model.put("contratos", contratos);
    return new ModelAndView("crud/contratoAux", model);
}