Here is my Jersey Service and I access the service using url
http://host:port/contextroot/welcome/data
When I map the Jersey servlet to /welcome/* – I get an an 404 error. But when I say /* in web.xml, my request goes through fine. I do not want all the requests in my webapp to go through jersey. How do i restrict the path to just requests with /welcome?
@Path("/welcome")
public class WelcomeRestJson {
@POST
@Path("/data")
@Produces("text/plain")
@Consumes("application/json")
public String processPostData(MyObject myObject) {
System.out.println("Inside processPostData");
return "success";
}
}
When mapping the servlet to /welcome/* simply change the path template of the root resource (WelcomeRestJson) from @Path(“/welcome”) to @Path(“/”) – that way the same URL (
http://host:port/contextroot/welcome/data) will work as before.