I am building servlets which implement a RESTful API. I understand the Jersey is a framework for deciphering and using given URL's. How do I use it in conjunction with the HttpServlet
class.
I don't understand how the two work with each other. I guess this is a very broadstrokes question but I have done a fair share of reading but am still stuck on this seemingly trivial concept. I have attempted to deploy apps with classes that extend the HttpServlet
class AND use Jersey annotations.
@Path("/api")
public class API extends HttpServlet{
@GET
@Path("/{name}")
@Produces("text/hmtl")
public String doGetSayHello(@PathParam("name") String name){
return "Hello" + name;
}
@GET
@Path("/articles")
@Produces("text/json")
public String doGetArticles(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
JSONObject obj = new JSONObject();
obj.put("interns", interns);
obj.put("company", "Stack Overflow");
return obj.toString();
}
}
Any help or informative materials would be greatly appreciated!