Example usage for javax.servlet.http HttpSession setAttribute

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

Introduction

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

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:com.tsg.techsupportmvc.HomeController.java

@RequestMapping(value = { "/links" }, method = RequestMethod.GET)
public String displayLinks(Model model, HttpSession session) {

    session.setAttribute("startTime", System.currentTimeMillis());
    session.setAttribute("page", "links");

    return "home";

}

From source file:com.tsg.techsupportmvc.HomeController.java

@RequestMapping(value = { "/tax" }, method = RequestMethod.GET)
public String displayTaxRates(Model model, HttpSession session) {

    session.setAttribute("startTime", System.currentTimeMillis());
    session.setAttribute("page", "tax");

    return "home";

}

From source file:br.edu.ifrn.pdscfyp.Controller.MainController.java

@RequestMapping("/logout")
public String logout(HttpSession session) {

    session.setAttribute("usuarioLogado", null);

    return "redirect:index";
}

From source file:com.tsg.techsupportmvc.HomeController.java

@RequestMapping(value = { "/knowledgeBase" }, method = RequestMethod.GET)
public String displayKnowledgeBase(Model model, HttpSession session) {

    session.setAttribute("startTime", System.currentTimeMillis());
    session.setAttribute("page", "knowledgeBase");
    session.setAttribute("js_page", "knowledgeBase.js");

    return "home";

}

From source file:demo.SessionController.java

@RequestMapping("/logging")
public String logging(@RequestParam(defaultValue = "false") boolean enable, HttpSession session) {
    if (enable) {
        session.setAttribute(LoggingKey.LOGGING_KEY, "true");
    } else {//from  w  w  w . ja  v  a2  s . c o m
        session.removeAttribute(LoggingKey.LOGGING_KEY);
    }
    return enable + "\n";
}

From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java

/**
 * Given a session and desktop id, returns Spring security context object.
 * /*from   w  w w  .j a  v  a2s  .com*/
 * @param session Session where security context is stored.
 * @param dtid Id of desktop whose security context is sought.
 * @return SecurityContext The Spring security context. First looks for the desktop-based
 *         security context. If not found, then looks for a session-based security context. This
 *         call will convert a session-based security context to desktop-based if a desktop
 *         identifier is found in the request object, a desktop-based security context does not
 *         exist, and a session-based security context does exist.
 * @throws IllegalStateException if session is invalidated
 */
private static SecurityContext getSecurityContext(HttpSession session, String dtid) {
    final String key = getDesktopContextKey(dtid);

    if (key == null) {
        return getSecurityContext(session, false);
    }

    // Check for desktop-associated security context
    SecurityContext securityContext = (SecurityContext) session.getAttribute(key);

    // If no desktop security context, check session.
    if (securityContext == null) {
        securityContext = getSecurityContext(session, true);

        // If session security context found and this is a managed desktop, move into desktop.
        if (securityContext != null) {
            session.setAttribute(key, securityContext);
        }
    }
    return securityContext;
}

From source file:controller.DeleteCustomerController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String customer_id = request.getParameter("id");
    System.out.println("Prdouct id: " + customer_id);

    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");

    HttpSession session = request.getSession();
    session.setAttribute("successmsg", "Customer Deleted Successfully");

    DbTable Delete_customer = (DbTable) context.getBean("DbTable");
    DbTable customerMng = (DbTable) context.getBean("DbTable");

    Delete_customer.DeleteCustomer(customer_id);

    ModelAndView model = new ModelAndView("ListCustomer");
    model.addObject("list", customerMng.getCustomer());
    return model;
}

From source file:org.alliance.rebel.tomcat.web.SampleController.java

@RequestMapping(value = "/setSession/{key}/{value}")
@ResponseBody/*  w  w w .  ja v a 2 s  .  c o  m*/
public String setSession(@PathVariable("key") String key, @PathVariable("value") String value,
        HttpSession session) {
    session.setAttribute(key, value);
    return session.getId();
}

From source file:org.openmrs.module.openhmis.cashier.web.controller.CashierSettingsControllerBase.java

@RequestMapping(method = RequestMethod.POST)
public void submit(HttpServletRequest request, CashierSettings cashierSettings, Errors errors,
        ModelMap modelMap) throws IOException {
    ModuleSettings.saveSettings(cashierSettings);

    HttpSession session = request.getSession();
    session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "openhmis.cashier.settings.saved");

    render(modelMap, request);//from w w w.j  a  v  a2 s.co  m
}

From source file:com.havoc.hotel.controller.CustomerLoginController.java

@RequestMapping(method = RequestMethod.POST, value = "checking")
public String filter(HttpServletRequest req, HttpServletResponse res) {
    String username = req.getParameter("username");
    String password = req.getParameter("password");
    Customer customer = customerDAO.authenticate(username, password);
    if (customer == null) {
        return "?check=failed";
    } else {//from  w  w w.j  av  a 2 s  .c o m

        HttpSession session = req.getSession();
        session.setAttribute("username", username);
        return "dashboard/dashboard";

    }

}