Correct me if I'm wrong, but it seems that many people are using RESTful web services to provide data to Ajax. However, a normal Servlet or PHP page can easily provide that information to Ajax applications. So, I don't see the benefit of creating web service, even a RESTful one, to provide data to Ajax calls.
So, my question is: what is the benefit of using a RESTful web service, rather than using a simple Servlet or PHP page to provide response to a Ajax application?
RESTful Web Services are using the HTTP protocol and HTTP Methods for invocation. RESTful Web Services doesn't have any special protocol like "big" (SOAP) Web Services have.
Therefore, Servlets can be used to create RESTful Web Services as well. In the matter of fact, if you create a simple Servlet with
doGet(-)
method, you've just created a RESTful Web Service servingGET
HTTP Method invocations.The same is with your simple PHP page.
If you're referring to RESTful Web Services as an i.e. JAX-RS implementation, than it buys you a flexibility and ease of development (
@Produces
,@Consumes
,@FormParam
, multiple@GET
methods etc.)