users@glassfish.java.net

Re: getServletContextName always returns empty string?

From: <glassfish_at_javadesktop.org>
Date: Thu, 11 Oct 2007 10:50:34 PDT

Hello and thanks for the clarification. So only the Servlet's getServletContextName() will return the correct value. I'm not sure why I encountered a scenario where my contextInialized was hit twice. I had a breakpoint set inside perhaps there is some retry timer logic that gets invoked if it doesn't succeed within a certain period?

In any case, thanks for the clarification.

S.D.

> Your context listener's contextInitialized() method
> should be invoked only once per context, regardless
> of how many servlets you have declared in your
> web.xml.
>
> Also, ServletContext.getServletContextName() is
> supposed to return the context's display-name (as
> specified in the web.xml), as opposed to the
> display-name of any of the servlets. I just verified
> that this works as intended.
>
> Jan
[Message sent by forum member 'samdoyle' (samdoyle)]

http://forums.java.net/jive/thread.jspa?messageID=239574