Difference between servlet and web service

前端 未结 7 770
死守一世寂寞
死守一世寂寞 2020-12-07 08:29

What is the difference between these 2? I found few results on google nothing conclusive.

Here is a follow up question:

Say I create spring mvc web app ann

7条回答
  •  甜味超标
    2020-12-07 09:14

    Web Service uses ServletContainer class which is again a Servlet class, which handles the request in clean and structured way. The REST stands for REpresentational STateless Protocol. Here the request won't store any data.

    The REST Web Service supports HTTP methods

    1. GET - Usually to fetch data.
    2. POST - To insert new Object.
    3. PUT - To update the existing Object.
    4. DELETE -To delete the Object.

    We can map any number of URLs to Web Service class which can have any type of HTTP methods.

    On other hand, there can be only 1 URL mapping can be done for each servlet. Though the end requirement can be achieved with the help of request parameter conditions, but using servlet nowadays won't provide clean way.

    In webservice we can define URL path at Class level as well as Method level, which allows us to code in more structured way.

提交回复
热议问题