{{theTime}}

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 = 
            context.getInitParameter(param);
          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)

        customPrefix.propertyvaluejava.lang.String


    servletUtils.SystemPropertiesHelper    

No comments:

Generate Models from SQL Server using Entity Framework Core

To generate models from SQL Server database tables using Entity Framework (EF) in .NET, you can follow the Database-First approach with Ent...