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:com.igame.app.controller.CouponController.java

@RequestMapping(value = "/modify", method = RequestMethod.POST)
@ResponseBody/*from  w w  w.  ja  v a2 s  .  com*/
public JSONObject modifyCoupon(@ModelAttribute("fm") CouponEntity couponEntity, HttpSession session) {
    long appid = ((SecUser) session.getAttribute("user")).getAppid();
    log.debug("CouponController --> addCoupon {}", JSON.toJSONString(couponEntity));
    couponService.modifyCoupon(appid, couponEntity);
    JSONObject jsonObject = new JSONObject(1);
    jsonObject.put("ret", 0);
    return jsonObject;
}

From source file:com.ntscorp.notice.interceptor.SessionInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    logger.info("HomeController   ");

    AuthCheck authCheck = ((HandlerMethod) handler).getMethodAnnotation(AuthCheck.class);

    if (authCheck != null) {
        HttpSession session = request.getSession();
        String userId = (String) session.getAttribute("userId");

        if (userId == null) {
            response.sendRedirect("login/form"); //? userid ?  ?? ? ...
            return false;
        }//from  w ww.  jav a2s.  co m
    }

    return true;
}

From source file:de.berlios.jhelpdesk.web.preferences.LookAndFeelEditController.java

@RequestMapping(value = "/preferences/lookAndFeel.html", method = RequestMethod.GET)
public String prepareForm(ModelMap map, HttpSession session) {
    User currentUser = (User) session.getAttribute("user");
    LookAndFeelPreferences lafPreferences = currentUser.getLafPreferences();
    map.addAttribute("preferences", lafPreferences != null ? lafPreferences : new LookAndFeelPreferences());
    return "preferences/lookAndFeel";
}

From source file:bookmarksave.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    System.out.println("executed");
    String productid = request.getParameter("productid1");
    Date date = new Date();
    SimpleDateFormat form = new SimpleDateFormat("dd/MM/yyyy");
    HttpSession session = request.getSession(true);
    String username = (String) session.getAttribute("username");
    System.out.println(username);
    String bookmarkdate = form.format(date);
    bookmarksbean bookmark = new bookmarksbean();
    bookmark.setProductid(productid);//from  w  ww  .  j a  v  a2  s  .  c  o m
    bookmark.setUsername(username);
    bookmark.setDateofbookmark(bookmarkdate);
    System.out.println(username + " " + productid);

    int count = bookmark.save();
    out.println("Bookmark Added");

}

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

@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody//from  w  w w . java2  s .  c o m
public JSONObject addCoupon(@ModelAttribute("fm") CouponEntity couponEntity, BindingResult result,
        HttpSession session) {
    long appid = ((SecUser) session.getAttribute("user")).getAppid();
    log.debug("CouponController --> addCoupon {}", JSON.toJSONString(couponEntity));
    couponService.addCoupon(appid, couponEntity);
    JSONObject jsonObject = new JSONObject(1);
    jsonObject.put("ret", 0);
    return jsonObject;
}

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

@RequestMapping(value = "/preferences/filters/{filterId}/details.html", method = RequestMethod.GET)
public String showFilter(@PathVariable("filterId") Long filterId, ModelMap map, Locale currentLocale,
        HttpSession session) {
    User currentUser = (User) session.getAttribute("user");
    TicketFilter filter = ticketFilterDAO.getById(filterId);
    if (filter != null && filter.isOwnedBy(currentUser)) {
        map.addAttribute("filter", filter);
    } else {/*w w w  .j a  v  a  2  s  . c  om*/
        map.addAttribute("errorMessage",
                ms.getMessage("customFilterController.showFilter.404", null, currentLocale));
    }
    return "preferences/filters/show";
}

From source file:de.berlios.jhelpdesk.web.tools.LocaleCustomResolver.java

public Locale resolveLocale(HttpServletRequest request) {
    Locale raLocale = (Locale) request.getAttribute("jhd_locale");
    if (raLocale != null) {
        return raLocale;
    }/*from w  ww.j av a  2 s  .  c o m*/
    HttpSession session = request.getSession();
    User currentUser = (User) session.getAttribute("user");
    if (currentUser != null && currentUser.getUserId() != null) {
        request.setAttribute("jhd_locale", currentUser.getPreferredLocale());
        return currentUser.getPreferredLocale();
    }
    Cookie localeCookie = WebUtils.getCookie(request, "jhd_locale");
    if (localeCookie != null) {
        Locale locale = StringUtils.parseLocaleString(localeCookie.getValue());
        if (locale != null) {
            request.setAttribute("jhd_locale", locale);
            return locale;
        }
    }
    request.setAttribute("jhd_locale", request.getLocale());
    return request.getLocale();
}

From source file:com.mtech.easyexchange.mvc.user.LoginController.java

@RequestMapping(value = "/login/failed", method = RequestMethod.GET)
public String loginFailed(ModelMap model, HttpSession session) {

    model.addAttribute("error", true);
    model.addAttribute("session", session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION"));

    return "user/login";
}

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

@RequestMapping(value = "buscarTodosContratosAdmin", method = RequestMethod.GET)
public ModelAndView buscarTodosContratosAdmin(ModelMap model, HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }//  ww w .j a  va 2s. c  om
    List<Contrato> contratos = busquedasContratos.buscarTodos();
    model.put("contratos", contratos);
    return new ModelAndView("crud/contratoAux", model);
}

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

@RequestMapping(value = "buscarPorEstadoAdmin/{idEstado}", method = RequestMethod.GET)
public ModelAndView buscarPorEstadoAdmin(@PathVariable("idEstado") Integer idEstado, ModelMap model,
        HttpSession session) {
    if (session.getAttribute(USUARIO) == null && session.getAttribute(CLIENTE) == null) {
        return new ModelAndView("templates/index");
    }//from  w w w.ja v a2 s. co m
    model.put("contratos", busquedasContratos.buscarPorEstado((idEstado)));
    return new ModelAndView("crud/contratoAux", model);
}