Search This Blog

Total Pageviews

Where to set the system properties in tomcat server.  Define

You can set the system parameters by specifying -D option (-Dcom.name.prop=value)

According to the Tomcat 6 docs, you'd have to write code like to use:

Context inictx = new InitialContext();
Context envCtx = (Context) inictx.lookup("java:comp/env");

// Look up our data source
String s = (String)envCtx.lookup("SMTP_PASSWORD");

 ServletContextListener set the System properties:
import java.util.Enumeration;
import javax.servlet.*;

public class SystemPropertiesHelper implements
        javax.servlet.ServletContextListener {
    private ServletContext context = null;

    public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();
        Enumeration params = context.getInitParameterNames();

        while (params.hasMoreElements()) {
          String param = (String) params.nextElement();
          String value = 
          if (param.startsWith("customPrefix.")) {
              System.setProperty(param, value);

    public void contextDestroyed(ServletContextEvent event) {
And then put this into your web.xml (should be possible for context.xml too)



No comments:

Cucumber Eclipse sample program

Cucumber Eclipse SetupCreate Eclipse Maven Project Open pom.xml Goto Dependencies Add GroupId: info.cukes, Artifact Id: cucumber-java, Versi...