Hi,
Context path in jboss-web.xml is mentioned as /Test, but my war file name is Test-0.0.1.
I need this war file name using HttpServlet. Please tell me the function name.
i tried getContextPath(), but it returns Test.
Thanks
views:
129answers:
2
A:
ServletContext.getContextPath() is the way to get the context path. It can differ from the war-file name, but I can't think of a reason you may need the war file name.
Bozho
2010-10-09 15:08:33
+1
A:
If the WAR is expanded, you could use ServletContext#getRealPath() in combination with File#getName() to obtain the expanded folder name. This will be the same as the WAR file name.
String name = new File(getServletContext().getRealPath("/")).getName();
BalusC
2010-10-09 15:16:55