java - GWT - Load a configuration item from context.xml -


i have gwt rpc application deployed tomcat 8, , want server code load configuration data (hostname , port service). otherwise service works fine. have read multiple suggestions cant work.

a snippet tomcat context.xml (i'm aware context.xml requires me restart tomcat when changed - ok).

<context reloadable="true">    <parameter name="config_hostname" value="192.168.2.199" override="false"/>   <parameter name="config_port" value="8888" override="false"/> 

in service implementation have setup() method. in try access config by:

string hostname = getservletconfig().getinitparameter("config_hostname"); string port = getservletconfig().getinitparameter("config_port"); 

however doesnt work. can put me on right track?

----------------------- update -------------------

i have tried putting info in web.xml this

<web-app> <context-param>     <param-name>hostname</param-name>     <param-value>192.168.2.199</param-value> </context-param> </web-app> 

and using (both works!) :

string h1=getservletconfig().getservletcontext().getinitparameter("hostname"); string h2=getservletcontext().getinitparameter("hostname"); 

however don't want put in web.xml since want have different setting each deployment. tomcat have conf/server.xml och conf/context.xml , have tried null in above calls then.

which best way of storing server-side configurations? please detailed in answer.

i have read doumentation @ http://tomcat.apache.org/tomcat-8.0-doc/jndi-resources-howto.html don't understand it.

i found answer here in tomcat docs @ /docs/config/context.html

the syntax in context.xml should (i correct beginnig here):

<context>   <parameter name="hostname" value="<some-ip-address>" override="false"/> </context> 

and call read should be:

getservletconfig().getservletcontext().getinitparameter("hostname");   or     getservletcontext().getinitparameter("hostname"); 

i'm sure have lot more learn (for example have separat params separate web applications in tomcat, now).


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -