How to get root context of a web application in Wicket
Written on
May 27, 2009 at 6:43 am by
mkyong
We always declared our root context as “display-name” in web.xml file as follow
<web-app> <display-name>swp</display-name> </web-app>
We can use the following method to get the root context in Wicket
WebApplication.get().getServletContext().getServletContextName()
Example
public static String getRootContext(){ String rootContext = ""; WebApplication webApplication = WebApplication.get(); if(webApplication!=null){ ServletContext servletContext = webApplication.getServletContext(); if(servletContext!=null){ rootContext = servletContext.getServletContextName(); }else{ //do nothing } }else{ //do nothing } return rootContext; }


