• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 549
  • Last Modified:

How to define/retrieve an application specific parameter in an J2EE application

I would like to define a application specific variable.  When the application start up, I can load it into some context variable.  Then, some java bean can access these context and do something with the defined variable.  Is there any way to do it?
1 Solution
>define a application specific variable.  
You could define one in your web app's web.xml ;
On a JSP, you could access with
String name = application.getInitParameter("name");
>Then, some java bean can access these context and do something with the defined variable  
(I think you are talking about a javabean here,not a EJB. Please confirm.)
That will take some more work. Please read jim's solution and my assisted solution at  
You can edit your server startup script and in the line when you start the server you can add -D params. -Dkey="Value". Inside your webapp or services or Jsp's you can get the parameter by System.getProperty("key")

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now