Interview Question
Qus: How do I know which version of a servlet I'm using on Java?
Answers (1)
There’s not really a better way to do this other than finding the differences in class structure and testing via reflection. This would be an extremely bad idea, btw. You should be targeting an API in most cases, rather than an implementation.
Please note that this is a bit confusing in earlier API releases because Java originally created specifications and expected Java EE partners to create implementations of the API. This meant that several of the early releases of Java EE have slight differences that were platform specific. For example, Jboss and Webmethods platforms had an extra method here or there in their implementations of the API to help them do something custom. That was remedied in later versions of Java and its respective APIs by making the APIs part of the Java codebase and only leaving implementations to the platforms.