You can't. That is because the context runs in some type of service which will present you with the requests. So only at request time can you know the hostname and port number of the server.

For example:
I have a web server which listens on ports 8080-8090 inclusive. That means that anyone could hit my web pages via:


http://www.ineedmorecowbell.net:8080/myPage.jsp
http://www.ineedmorecowbell.net:8081/myPage.jsp
http://www.ineedmorecowbell.net:8082/myPage.jsp

And I could complicate things furthur by adding another ip address to my server so I could also say:

http://igotthefeverandtheprescriptionismorecowbell.net:8080/myPage.jsp
http://igotthefeverandtheprescriptionismorecowbell.net:8081/myPage.jsp
http://igotthefeverandtheprescriptionismorecowbell.net:8082/myPage.jsp

In this scenario, myPage.jsp could be hit by many different ip addresses and different ports.

-Tim

rf wrote:
In my Web app startup contextListener I want to
initialize certain variables using the hostname and
port of the server. I dont see a way to obtain these
two values from ServletContext, can somebody help me?

Thanks
rf


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to