File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Rest web service and normal servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Rest web service and normal servlet" Watch "Rest web service and normal servlet" New topic

Rest web service and normal servlet

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
What is the difference between rest web service and a normal servlet that return xml data. ?

Ganesh Kandisa

Joined: Jul 27, 2011
Posts: 6

I think difference lies in the way they get input content instead of the return type. Servlet gets only HttpRequest/HttpResponse objects where as for REST method you have control how you will provide input to it..

Ganesh Kandisa

Ganesh Kandisa
OCPJP 6(93%),OCPWCD 5(92%)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
There isn't necessarily a difference. A servlet returning XML could be considered a web service if it adheres to the REST principles.

It's probably more common for REST services to use JSON than XML, but the data format is not a defining characteristic of REST.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
REST calls for a strict architectural style, as the Wikipedia article Ulf cites explains.

There is no restriction (XML, JSON, whatever) on the kind of resource a RESTful service can respond with.

In addition to the common GET, and POST requests, a RESTful server may be designed to handle other HTTP actions such as DELETE, PUT, HEAD. and (with HTTP1.1), PATCH.

I agree. Here's the link:
subject: Rest web service and normal servlet
It's not a secret anymore!