Thursday, December 18, 2008

Servlet API and available ports of the application server

Servlets are something we heavily used in Application server environment. And it provide accessing most of the information we need about the application sever and the context. However it does not provide a way to get the type of ports that is being exposed. For example a servlet may be exposed in HTTP (8080) and HTTPS (8443), then it would be able to get those port information from the servlet API. All those informations are available at the application server, so why not servlet API expose those information.

3 comments:

David Illsley said...

Um, how about request.getServerPort()

Deepal Jayasinghe said...

The problem of that is you have to wait till you get the first request.

Say you want to find the port without getting a request, then we have a problem.

Afkham Azeez said...

Ideally, there should be some way to get this information when the servlet is initialized.

One other thing is that it is possible to have multiple ports (even multiple HTTP & HTTPS ports) on a single app server.