Is it possible to know in my Java code the port where a Java EE application has been deployed?
Is it possible to do a not container spec开发者_如何学Pythonific solution?
Thanks a lot in advance.
Edit: It whould be nice if this is discovered in a ServletContextListener
since it will be done on startup.
If you have a handle of the HttpServletRequest
, then you can get it by ServletRequest#getServerPort()
(the port which the client used) and/or ServletRequest#getLocalPort()
(the port which the server actually uses --which might not be visible for the client due to router/proxy), depending on which port exactly you'd like to know about.
精彩评论