Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between servlet and restful webservice  RSS feed

 
Ranch Hand
Posts: 138
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel your question is more about soap vs rest. You would get lot of articles on google talking about pros and cons.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 75
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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"?
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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).
 
Greenhorn
Posts: 15
Oracle VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!