Example usage for javax.servlet.http HttpServletRequest setAttribute

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

Introduction

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

Prototype

public void setAttribute(String name, Object o);

Source Link

Document

Stores an attribute in this request.

Usage

From source file:com.serotonin.m2m2.Common.java

public static User getUser(HttpServletRequest request) {
    // Check first to see if the user object is in the request.
    User user = (User) request.getAttribute(SESSION_USER);
    if (user != null)
        return user;

    // If not, get it from the session.
    user = (User) request.getSession().getAttribute(SESSION_USER);

    if (user != null) {
        // Add the user to the request. This prevents race conditions in which long-ish lasting requests have the
        // user object swiped from them by a quicker (logout) request.
        request.setAttribute(SESSION_USER, user);
    }//from   w w w .  j  av a2  s . c  om
    return user;
}

From source file:com.uds.sauvage.controller.WelcomeController.java

@RequestMapping(value = "/", method = RequestMethod.GET)
public String listAll(Model model, HttpServletRequest req) {
    System.out.println("Je passe la");
    req.setAttribute("base_url", req.getContextPath());
    model.addAttribute("surveys", surveyService.getAll());
    model.addAttribute("page", "welcome.jsp");
    System.out.println("passage " + req.getContextPath());
    return "index";
}

From source file:com.denksoft.springstarter.web.WelcomeController.java

@RequestMapping({ "/public/populate.task" })
public void populateDatabase(HttpServletRequest request) {
    request.setAttribute("populated", publicService.populate());
    request.setAttribute("users", publicService.getUsers());
}

From source file:com.jaspersoft.jasperserver.war.tiles2.Tiles2TestController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

    request.setAttribute("author", "Stas");
    return new ModelAndView("tiles/about");
}

From source file:org.shredzone.cilla.view.interceptor.FramedViewInterceptor.java

/**
 * Sets up generic attributes common to all views using a standard frame.
 *//* w  ww.j  a va 2 s  .c o  m*/
public void setupFrame(HttpServletRequest req, HttpServletResponse resp) {
    req.setAttribute("headerImage", headerDao.fetchRandomHeader());
    req.setAttribute("rootCategories", categoryDao.fetchRootCategories());
}

From source file:com.synjones.user.controler.UserController.java

@RequestMapping("get/{sno}")
public String queryUserById(@PathVariable("sno") String sno, HttpServletRequest request) {
    User findUserBySno = userMapper.findUserBySno(sno);
    request.setAttribute("user", findUserBySno);
    return "query_user";
}

From source file:com.wx.spring.controller.UserController1.java

@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request) {

    request.setAttribute("userList", userManager);

    return "/index";
}

From source file:com.wx.spring.controller.UserController1.java

@RequestMapping("/getUser")
public String getUser(String id, HttpServletRequest request) {

    request.setAttribute("user", userManager.findCustomerById(id));

    return "/editUser";
}

From source file:com.roncoo.pay.controller.exception.WebExceptionHandler.java

/**
 * /*from   w  ww  .  java  2  s. co  m*/
 */
@ExceptionHandler({ Exception.class })
@ResponseStatus(HttpStatus.OK)
public String processException(Exception e, HttpServletRequest request) {
    LOG.error("Exception", e);
    request.setAttribute("msg", "");
    return "common/error";
}

From source file:com.redhat.rhn.frontend.action.kickstart.PowerManagementAction.java

/**
 * Ensure a fence agent is installed, raise an error and disable fields if not
 * @param request the current request//from  w  w w.j  a v  a 2 s . c  om
 * @param strutsDelegate the Struts delegate
 * @param errors ActionErrors that might have already been raised
 */
public static void ensureAgentInstalled(HttpServletRequest request, StrutsDelegate strutsDelegate,
        ActionErrors errors) {
    // written this way instead of one rpm command because if any of the rpms passed
    // to a single rpm command are not installed the return status is 1
    String[] rhelRpm = { "rpm", "-q", "fence-agents" };
    String[] fedoraRpm = { "rpm", "-q", "fence-agents-all" };
    String[] fedoraSpecificRpm = { "rpm", "-q", "fence-agents" };
    SystemCommandExecutor ce = new SystemCommandExecutor();
    if (ce.execute(rhelRpm) != 0 && ce.execute(fedoraRpm) != 0 && ce.execute(fedoraSpecificRpm) != 0) {
        strutsDelegate.addError(errors, "cobbler.powermanagement.no_fence_agents");
        strutsDelegate.saveMessages(request, errors);
        // overwrite types with an empty list to disable pages
        request.setAttribute(TYPES, new TreeMap<String, String>());
    }
}