Test class:
@Path("/test")
public class TP {
private static Logger log = Logger.getLogger(TP.class);
@GET
@Produces("text/plain")
public String testContext(@Context ServletContext servletContext) {
StringBuilder sb = new StringBuilder();
sb.append("init parameters: \n\r");
java.util.Enumeration penum = servletContext.getInitParameterNames();
for ( ; penum.hasMoreElements()
{
String name = (String)penum.nextElement();
sb.append( name + "=" + servletContext.getInitParameter(name) + "\n\r" );
}
return sb.toString();
}
}
web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>testing</display-name>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>aa</param-name>
<param-value>pleasework</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/service</param-value>
</context-param>
</web-app>