1

I am doing a web site with Spring MVC.

I am hoping to build a feature for the admin. As an admin, I would like set a value, which is accessible to all user sessions.

As you know, I can set a value in session, but it is only available to me. I am hoping to set a value accessible to all others in the same JVM.

What is the Java web feature for me to achieve my goal?

I already implemented a database-based feature which affects the users across all servers in a cluster. Now I would like to have a non-database per-JVM solution.

halfer
  • 19,824
  • 17
  • 99
  • 186
curious1
  • 14,155
  • 37
  • 130
  • 231

2 Answers2

2

You can use the attributes of the ServletContext which is the context of the web application.

In this SO question you can find a reference of how to access and use it.

Community
  • 1
  • 1
fmodos
  • 4,472
  • 1
  • 16
  • 17
  • 1
    fmodos, thanks for the info!!! I recall this servlet feature now. I will read that and come back later to select yours as the answer. – curious1 Nov 14 '15 at 14:03
1

If you are using web.xml in your application then you can do something like this

<web-app>  
 ......  

  <context-param>  
    <param-name>paramName</param-name>  
    <param-value>paramValue</param-value>  
  </context-param>  
 ......  
</web-app>    

If you are using annotations then, you can find all javax.servlet annotations in the javax.servlet.annotation package summary.

refer this link for detailed info

Community
  • 1
  • 1
RockAndRoll
  • 2,247
  • 2
  • 16
  • 35
  • Hi Prince Mani Gupta, thanks for your information. Good to know the approach you mentioned. Cheers! – curious1 Nov 14 '15 at 14:16