I am working with Web-Application (
TestApp). In this application i used to implement the ServletContextListener(as ContextListener) and
contextInitialized(ServletContextEvent event) method contains the following code segment.
ServletContext servletContext = event.getServletContext();
// where event is ervletContextEventURL
String servletPath = servletContext.getContextPath()+"/MyServlet";
// MyServlet is URL of the
Servlet
URL servletURL = sevletContext.getResource();
Here i am trying to get the complete URL of MyServlet ( expected
servletURL =
http://localhost:8080/TestApp/MyServlet) but it always returns '0'.
And servletContext.getContextPath() always returns /TestApp (expected
http://localhost:8080/TestApp).
Anybody please suggest me that is there any way to find URL of context(
http://localhost:8080/TestApp)
OR particular Servlet from ServletContext(
http://localhost:8080/TestApp/MyServlet).
Using ApplicationServer :
Jboss AS 7.1.1