Is it possible to know which JEE Container is being used during Dispatcher Servlet initialization?

3

After some difficulties with the use of Spring Security and JBoss using annotations based on API Servlet 3 (Servlet 3.1 specifically), I found that when using the Spring with JBoss , particularly JBoss EAP 6.1+, you can not do the mapping Dispacher Servlet for the URL " / " simply, it is necessary that such mapping is done to the URL " / * " .

To resolve this problem came to create a fork to study this problem, and this is the link: link where already tested the example" Insecure MVC "and this fix resolves the problem.

But I am developing an application that will run on many containers , and I fear that may come to have problems with other resources, and so I need to parameterize the startup servlet.

In this case does Spring give me some feature to identify which container is running?

How to do this?

    
asked by anonymous 10.07.2015 / 18:24

1 answer

5

You can create a class to initialize WebApp that implements the WebApplicationInitializer .

This interface has a single method that receives a ServletContext and by ServletContext you can get the name of the server.

public class WebAppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext context) throws ServletException {
        System.out.println(context.getServerInfo());
    }

}

Console output:

    
10.07.2015 / 19:37