Programmatically retrieve container information with an embedded servlet

I have a Spring boot application. I want to display the current name and version of the servlet container on the Admin Console page.

My application currently uses Tomcat, but I want to automatically display the same information if I had to, say, switch to Jetty or some other built-in servlet container.

This information is not available (at least it seems) through Environmentor endpoints Actuator.

How can I programmatically get the embedded name and version of a servlet container?

+4
source share
1 answer

You can get the information you need from ServletContext.

:

@Autowired ServletContext context;

:

context.getServerInfo()

Spring Boot Tomcat :

Apache Tomcat/8.5.27
+4

Source: https://habr.com/ru/post/1692328/


All Articles