As far as I know, when administrator installs .war file into the application server, application server determines Servlet Standard version used by this .war file by looking at web.xml file:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
here is Servlet 3.1 declaration.
But with modern Servlet Standards, web.xml file is optional and most of the functionality is achievable with annotations such as @WebServlet. But if I omit this web.xml file, how does application server determine the Servlet Standard version I used to develop my application?