• 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?
0
jaxox
Asked:
jaxox
1 Solution
 
rrzCommented:
>define a application specific variable.  
You could define one in your web app's web.xml ;
<context-param>
                          <param-name>name</param-name>
                          <param-value>jaxox</param-value>
</context-param>  
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  
http://www.experts-exchange.com/Programming/Languages/Java/J2EE/JSP/Q_21811332.html   
0
 
sunray_2003Commented:
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")
0

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