*
The moose likes Web Services and the fly likes Difference between servlet and restful webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Difference between servlet and restful webservice" Watch "Difference between servlet and restful webservice" New topic
Author

Difference between servlet and restful webservice

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
What is the difference between a servlet and a restful webservice,in terms of 'can do' and 'cant do'.

I believe Restful WS dilutes a lot of the bootstrapping available with SOAP-based WS like QoS,state,security,contract etc.
Then what does it provide over a normal servlet?
What design criteria should decide that I prefer a Restful WS over a generic servlet-based web module?

Secondly,What would frameworkds like Jersey,Restlet provide over a generic servlet,except perhaps an ease of development.

The differences are very subtle for me - so would appreciate if someone had insights.

shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
I feel your question is more about soap vs rest. You would get lot of articles on google talking about pros and cons.


SCJP 1.5(97%) My Blog
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Wikipedia has a quite good article on REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
I recommend at least taking a look at the key goals and constraints section.
REST is an architectural principle; by adhering to the constraints, one can reach the (key) goals.
You can do whatever you want to do, but if you do not adhere to the constraints then you will be less likely to reach the goals.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Secondly,What would frameworkds like Jersey,Restlet provide over a generic servlet,except perhaps an ease of development.


Ease of development and widely understood conventions are about it, for the simple reason that the RESTful principles are simple.

As Ivan said, it is an architectural / style principle. It is instructive to read Fielding's original PhD thesis on the topic.

Note that many many services claiming to have a RESTful interface do not stick to Fielding's definitions, so be skeptical.

Bill
Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75

Ranadhir Nag wrote:What is the difference between a servlet and a restful webservice,in terms of 'can do' and 'cant do'.


I am confused as well!!!

For me, restful web service is just "annotated" servlet, accepting http request and replying http response!

And does resful web service provide "java client"?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Leon Omk wrote:For me, restful web service is just "annotated" servlet, accepting http request and replying http response!

REST is based on using all HTTP methods -which include PUT and DELETE-, so thinking about REST in terms of servlets -which almost exclusively use GET and POST only- does not get at their full capabilities, nor at the actual RESTful architecture style.

And does resful web service provide "java client"?

The service is a service, not a client. Any particular REST implementation -like Jersey- may provide tools or APIs for accessing REST services (and Jersey does so).
Ulli Hertlein
Greenhorn

Joined: Jan 13, 2011
Posts: 15

Ranadhir Nag wrote:What is the difference between a servlet and a restful webservice,in terms of 'can do' and 'cant do'...


thats what i asked myself too: look at this thread:
http://www.coderanch.com/t/523478/Web-Services/java/RESTful-Architecture-vs-servlet-Framework

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between servlet and restful webservice
 
Similar Threads
generic servlet and http servlet
What is the difference between servlet and webservice.
servlet
Web services security
difference between restful webservice and jersey webservice