I have connector tag configured in server.xml as below.
<Connector port="8080" bindOnInit="false" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
I want to read value of bindOnInit parameter at runtime using java code. I do not want to parse the xml. As i searched i found that i can get data from Tomcat tomcat = new Tomcat(); tomcat object. How can i get existing tomcat object instead of creating new one because creating new tomcat object will not give me configured value.
Please help in reading bindOnInit parameter at Runtime using java code.
Thank you in advance.
You must recover the
org.apache.catalina.server.StandardServer
using MBeanServer. This is the root entry for all Tomcat system elements:I've tested with this connector configuration:
And this is the log output:
You can see that the
binOnInit
property can be accessed through thegetProperty()
orgetAttribute()
methods of the Connector, and that it actually returns thefalse
value for AJP connector: