2

I would like to print (as debug info) the type and version of the App Server my webapp is running on.

With a little search so far I was able to come up with this via the org.springframework.core.env.Environment:

this.environment.getProperty("java.naming.factory.initial")

However it just says "org.apache.naming.java.javaURLContextFactory" and not like "Apache Tomcat/8.0.33" which I would like to see.

Csuki
  • 1,297
  • 8
  • 21

1 Answers1

2

Use ServletContext.getServerInfo()

Btw: In Spring you can inject ServletContext

@Service
public class ServerLoggingService() {

  @Autowired
  private ServletContext servletContext;

  @PostConstruct
  public void printServer() {
      System.out.println("Server Version: " + this.servletContext.getServerInfo());
  }
}
MagGGG
  • 19,198
  • 2
  • 29
  • 30
Ralph
  • 118,862
  • 56
  • 287
  • 383