开发者

Is it possible to retrieve the port where a Java EE application is deployed

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜