Search code examples
jakarta-eewebsphere

WebSphere Portal: name space bindings. How to Get a Variable?


I have a String variable that is binded to a WebSphere Portal (via admin console): Binding type : string | Binding identifier : threshold | Name in name space : repos/threshold | String value : 30

Now, I need to get this variable in my enterprise app, which is deployed on this portal. I've heard that it can be done with a help of ExternalContext. Maybe there are other ways. Please, give me an example and explanation =)


Solution

  • Dmitry,

    I have just succeeded in doing this using the following code:

    Context initial_ctx;
    initial_ctx = new InitialContext();
    String threshold = (String) initial_ctx.lookup("repos/threshold");
    

    Although in my case the Name in the Name space was just "theshold".

    You may need to check the "Scope" of your Name Space Binding as defined in the Websphere admin console. It may need to match the value returned by the call to "initial_ctx.getNameInNamespace()". It did in my case, but that may not be necessary or sufficient.