In Netbeans the web.xml is located in
WAR-Project with Maven
- Web Pages
- WEB-INF
- web.xml
In the folder structure its located in:
WAR-Project with Maven
- src
- main
- webapp
- WEB-INF
- web.xml
There you can define the Jersey Servlet:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
<!-- Jersey -->
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>package.path.to.your.rest.service;</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Now you can access your REST-Service under following URL:
localhost:8080/HelloWorld/rest/test/printHello