Shamim Hafiz - MSFT
Shamim Hafiz - MSFT

Reputation: 22134

Are Java Servlets equivalent to Web Services

I am familiar with Creating and consuming Web Services using .NET/PHP, but not familiar with Java Servlets.

Are they just equivalent to creating Web Services using .NET?

Upvotes: 1

Views: 1124

Answers (6)

Y.S. Chen
Y.S. Chen

Reputation: 61

No, It is the only way to implement Web Service which have two protocol,not only use SOAP,which too heavy,you can use lightweight protocol RESTFul.

Using NetBean develop very quickly.

Upvotes: 0

Buhake Sindi
Buhake Sindi

Reputation: 89209

No, Servlets, which conforms to the Java Servlet API, is a protocol used for responding to requests (server requests). As mentioned by Jon Skeet (see comment, and thanks for the clear-up), servlets are protocol-neutral (They are not tied to a specific client-server protocol). HttpServlet is a Servlet that responds to HTTP requests. In Java, SOAP Web Services engines are written with a Servlet as a container to handle HTTP Web Services requests (with the exception of RMI Invocating Web Services).

Resources:

Upvotes: 1

weltraumpirat
weltraumpirat

Reputation: 22604

No, they are not.

Java servlets can be used to implement web services, but the two concepts apply to different levels of abstraction:

A servlet is generally any Java class that runs on a web server and implements the Java Servlet Specification. This includes methods to receive, process and respond to HTTP requests, among others.

A web service is a specific way to establish machine-to-machine communication within a network, and can be implemented using a variety of protocols, technologies, and even paradigms.

Upvotes: 2

shinynewbike
shinynewbike

Reputation: 2352

No they are not the same.

A web service uses SOAP protocol and returns you XML, a servlet returns you HTML which you view in the browser

Upvotes: 0

Vineet Reynolds
Vineet Reynolds

Reputation: 76729

No, they are not.

The closest equivalent to Servlets in the .Net framework is the HttpHandler. However, I consider servlets to be far more easier to work with, than HttpHandlers.

Most of the HTTP-based processing of requests is performed eventually by servlets, in a JavaEE container. This is true even of most web-services in Java, where one can write a web-service in a particular framework, but eventually a servlet is usually responsible for performing the heavy-lifting. The same holds good for Java Server Pages (JSPs, which are compiled to servlets), and JSF (where a controller servlet - FacesServlet is responsible for processing of requests).

Upvotes: 2

systemsfault
systemsfault

Reputation: 15547

No definitely not, standard definition: a servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Servlets are not tied to a specific client-server protocol but they are most commonly used with HTTP and the word "Servlet" is often used in the meaning of "HTTP Servlet". Whereas a web service is programmable application logic accessible via standard Web protocols such as SOAP using XML.

Upvotes: 5

Related Questions