We can set the request attributes using Model
or ModelAndView
object in Spring.
We can use @SessionAttributes
to keep attributes
In the spring you can get application scope by using @Autowired annotation
@Autowired
private ServletContext servletContext;
Then you can access you element by using .getAttribute Method
Object someObj = servletContext.getAttribute("object",someObj);
if(someObj==null)
someObj = new Object(); //This will create new Object if it doesn't exists.
servletContext.setAttribute("object",someObj);