Hi,
glassfish_at_javadesktop.org wrote:
> Is there anyway to determine what port a glassfish instance is running on?
>
> What I'm trying to do, is on startup have a servlet register itself with a servlet in another web app on the same server.
>
> So when FooServlet starts up and wants to register itself with the DirectoryServlet, there's no way for me to build the full URL to the directory. I know the host (localhost) and the url to the servlet (/Directory/Register) but I don't know the port number. So that means that if glassfish isn't running on port 80, the registration will fail.
>
> Worst case scenario, I could make the port configurable in the applications, but I'd prefer if there were some way of finding this information from glassfish.
> [Message sent by forum member 'jodeen' (jodeen)]
>
You cannot find the port information as startup, but you can at runtime.
The HttpServletRequest has a method called getLocalPort() which is what
you are looking at I guess:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getLocalPort()
If you need it at startup, there might be a way to use AMX/JMX to
consult the mbean and locate the Grizzly mbean (but still you will get
several ports if there is more than one listener...not to say your
solution will not be portable across container).
Thanks
-- Jeanfrancois
> http://forums.java.net/jive/thread.jspa?messageID=233084
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>