Container Objects

Container objects HttpServletRequest, HttpServletResponse and HttpSession can be sent to a Controller's method using method arguments.

Here is an example controller ContainerObjectCtl that passes container objects to a controller method.

@Controller

@RequestMapping(value = "/ContainerObj")

public class ContainerObjectCtl {

@RequestMapping(value = "/Request", method = RequestMethod.GET)

public String injectRequest(HttpServletRequest request, HttpServletResponse response, Model model) {

//...

return "ContainerObjectView";

}

@RequestMapping(value = "/Session", method = RequestMethod.GET)

public String injectSession(HttpSession session, Model model) {

//...

return "ContainerObjectView";

}

@RequestMapping(value = "/All", method = RequestMethod.GET)

public String injectAll(HttpServletRequest request,HttpServletResponse response, HttpSession session, Model model) {

//...

return "ContainerObjectView";

}

}