How do I set a System Property and access it from a Servlet?

Dane Foster

I am using JAXP for parsing xml documents.
With JAXP we specify the parser to use in system property named "javax.xml.parsers.SAXParserFactory". The related function createXMLReader() automatically takes this value from system.

Now the purpose of this approach is to make your code portable across different vendor for parsers.

How can i specify a system property out side the servlet so that createXMLReader() can get it on its own...thus true vendor independence can be obtained???

Answer: Most servlet engines allows you to pass parameters to the VM when its starting. Find out how your servlet engine does this and pass:


[This will probably be in the servlet container's startup script. E.g. for Tomcat this will be either tomcat.sh, tomcat.bat, catalina.sh, or catalina.bat. For WebLogic it is startWebLogic.bat. Etc... -Alex]