This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When you say "at startup" can you be more specific about what point you need this...Do you mean server startup? Do you mean when the webapp is started? What do you need it for? Someone may be able to give more advice with a little more detail. I've only ever done this kind of thing from an HTTPRequest, so I'm not sure what to suggest.
The server might be getting HTTP and HTTPS requests, so that would mean different ports on different requests. Therefore you can't get "the port" unless you have a request at hand, and you can ask what port it came into.
Likewise you can't tell whether the request was sent to the server using its name or its IP address. And a server can be configured to have more than one name. Therefore you can't get the host part of the URL either, unless you have a request at hand.
Joined: Mar 13, 2005
Thanks for the replies.
This is the requirement,I want the webapplication to generate its path along with context and port and report it to an another admin application (the reporting is done through xml over http) . The admin module stores this info in the db.
I have a singleton that I initialize when the context is created and starts a thread to communicate with the admin app, this thread carries the report to the admin app which among other things tells the full path. So I was looking to add this path generating feature to that singleton.
On looking at the servlet api I too concluded that the request is needed to get the port but I wanted to make sure I am not missing something obvious.