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;
 
	}