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:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java

@RequestMapping(value = "/preferences/lookAndFeel.html", method = RequestMethod.POST)
public String processForm(@ModelAttribute("preferences") LookAndFeelPreferences lafPreferences,
        @RequestParam(value = "filterId", required = false) Long filterId, HttpServletRequest request,
        HttpServletResponse respone, ModelMap map, HttpSession session) {
    User currentUser = (User) session.getAttribute("user");
    if (isPrefsOwnedByUser(lafPreferences, currentUser)) {
        lafPreferences.setUser(currentUser);
        currentUser.setLafPreferences(lafPreferences);
        this.userPreferencesDAO.save(lafPreferences);
        respone.addCookie(createCookie(request, lafPreferences.getPreferredLocale()));
        session.setAttribute("user", currentUser);
        map.addAttribute("preferences", lafPreferences);
    }/*from w ww  .j a  v a  2 s.c  o m*/
    return "preferences/lookAndFeel";
}

From source file:org.hifivault.geo.location.GeoLocationManager.java

public GeoInfo getGeoInfo(HttpSession session) {
    Object geoi = session.getAttribute(getGeoInfoAttribute());
    if (geoi == null)
        return null;
    if (!(geoi instanceof GeoInfo)) {
        log.error("GeoInfo: ERROR: bad atttibute " + getGeoInfoAttribute() + ": (" + geoi.getClass().getName()
                + ")");
        return null;
    }/*from  ww  w. j av  a2s. co  m*/
    GeoInfo mp = (GeoInfo) geoi;
    return mp;
}

From source file:util.EgovWebSocketMessengerController.java

/**
 *   ? ??.// w  w w.j  a  v  a  2s. com
 * @param session ?
 * @param model ?
 * @return view name
 */
@IncludedInfo(name = " ", order = 3200, gid = 100)
@RequestMapping(value = "/cop/msg/websocketMessengerView.do")
public String websocketMessengerView(HttpSession session, ModelMap model) {
    model.addAttribute("loginVO", session.getAttribute("loginVO"));
    return "egovframework/com/ext/msg/EgovMessenger";
}

From source file:com.liferay.portal.util.PortalUtil.java

public static String getUserId(HttpSession ses) {
    if (ses != null && ses.getAttribute(WebKeys.USER_ID) != null) {
        return (String) ses.getAttribute(WebKeys.USER_ID);
    } else {//from   w  w  w.j  a  v a  2  s  .c  om
        return null;
    }
}

From source file:miage.ecom.web.controller.ProductController.java

@RequestMapping(value = "/products/store/{storeId}", method = RequestMethod.GET)
public String productsForStore(@PathVariable("storeId") Integer storeId, Model model, HttpSession session) {
    CartBean cart;//from  www .j  a v a2 s . co m
    if (session.getAttribute("cart") == null) {
        cart = new CartBean();
    } else {
        cart = (CartBean) session.getAttribute("cart");
        session.setAttribute("cart", cart);
    }

    model.addAttribute("cartTotalValue", ecomBeanFrontLocal.getTotalValue(cart));
    model.addAttribute("nbProducts", ecomBeanFrontLocal.getCartContents(cart).size());
    List<Category> categories = categoryFacade.findAll();
    model.addAttribute("categories", categories);

    List<Product> products = storeFacadeLocal.findProductsByStore(storeId);
    model.addAttribute("products", products);
    model.addAttribute("store", storeFacadeLocal.find(storeId));

    return "store";
}

From source file:com.starr.smartbuilds.controller.IndexController.java

@RequestMapping(method = { RequestMethod.GET })
public String getIndex(Model model, HttpServletRequest req) throws IOException, ParseException {
    HttpSession session = req.getSession();
    User user = (User) session.getAttribute("user");
    if (user == null) {
        model.addAttribute("authMsg", "<a href='./auth'>Log in</a>");
        model.addAttribute("exitReg", "<a href='./reg'>Register</a>");
    } else {/*from w  w  w.j a va  2  s  . co  m*/
        model.addAttribute("authMsg", "Hello," + user.getSummonerName() + "!");
        model.addAttribute("exitReg", "<a href='./auth/exit'>Exit</a>");
        model.addAttribute("createbuild", "<li><a href='./add' style='color: #deff00;'>Create Build</a></li>");
    }
    List<Champion> champions = championDAO.listChampions();
    List<Build> builds = buildDAO.listBuilds();
    List<Build> builds_new = new ArrayList();

    if (builds.size() >= 5) {
        for (int i = 0; i < 5; i++) {
            builds_new.add(builds.get(i));
        }
    } else {
        builds_new = builds;
    }

    model.addAttribute("recent", builds_new);
    model.addAttribute("champions", champions);

    return "index";
}

From source file:edu.pitt.sis.infsci2730.finalProject.web.OrderHistoryController.java

@RequestMapping(value = "", method = RequestMethod.GET)
public ModelAndView mypage(HttpSession session) {
    try {//from w  w  w.j  a  va  2s .com
        CustomerDBModel customer = (CustomerDBModel) session.getAttribute("customer");
        Map<String, Object> myModel = new HashMap<String, Object>();
        if (customer == null) {
            return new ModelAndView("index");
        } else {
            List<TransactionDBModel> l = this.transactionServie
                    .GetTransactionByCustomerID(customer.getCustomer_id() + "");
            for (int i = 0; i < l.size(); i++) {
                TransactionDBModel t = l.get(i);
                t.setTotoalAmount(this.transactionServie.GetTranactionTotalAmount(t.getTransaction_id() + ""));
            }
            myModel.put("transactionList", l);
            return new ModelAndView("orderHistory", "modelMap", myModel);
        }
    } catch (Exception ex) {
        Logger.getLogger(OrderHistoryController.class.getName()).log(Level.SEVERE, null, ex);
        return new ModelAndView("500");
    }
}

From source file:util.EgovWebSocketMessengerController.java

/**
 * ?  ?.//from w  w w. j av  a 2  s.c o  m
 * @param roomId  ?
 * @param username ? ?
 * @param session ?
 * @param model ?
 * @return view name
 */
@RequestMapping(value = "/cop/msg/websocketMessengePopup.do")
public String websocketMessengePopup(@RequestParam(value = "roomId") String roomId,
        @RequestParam(value = "username") String username, HttpSession session, ModelMap model) {
    model.addAttribute("loginVO", session.getAttribute("loginVO"));
    model.addAttribute("roomId", roomId);
    model.addAttribute("username", username);
    return "egovframework/com/ext/msg/popup/chatPopupBubble";
}

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

@RequestMapping(value = "empresa", method = RequestMethod.GET)
public String empresa(Model model, HttpSession session) {
    Usuario usuario = (Usuario) session.getAttribute("usuario");
    List<Permiso> permisos = (List<Permiso>) session.getAttribute(PERMISOS);

    if (usuario == null || permisos == null) {
        return "templates/index";
    }//w  w w  . j  a v a 2s  .  c  o m
    if (usuario.getEsAdmin()) {
        model.addAttribute("esAdmin", "esAdmin");
    }
    if (usuarioService.tienePermiso(usuario, "empresa")) {
        return "templates/noAutorizado";
    }
    model.addAttribute("permisos", permisos);
    model.addAttribute("empresa", empresaService.buscarTodos());
    return "crud/empresa";
}

From source file:org.meruvian.yama.webapi.interceptor.LoggedInFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    HttpSession session = req.getSession(true);
    SecurityContextImpl sci = (SecurityContextImpl) session.getAttribute(SPRING_SECURITY_CONTEXT_KEY);

    if (sci == null) {
        chain.doFilter(request, response);
        return;//from  w  w  w.j  a v a  2 s. c om
    }

    res.sendRedirect(StringUtils.join(req.getContextPath(), SecurityConfig.LOGIN_SUCCESS_URL));
}