• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

statelessness rest webservice

 
Ranch Hand
Posts: 930
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i was reading as below
https://www.tutorialspoint.com/restful/restful_statelessness.htm

what is the meaning of below

Consider the following URL −

https://localhost:8080/UserManagement/rest/UserService/users/1

If you hit the above url using your browser or using a java based client or using Postman, result will always be the User XML whose Id is 1 because the server does not store any information about the client.

<user>
  <id>1</id>
  <name>mahesh</name>
  <profession>1</profession>
</user>



how result with id 1 is related to statelessness.

since we created new user it created with id 1 and while retrieving we get same value right.

please advise
 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Statelessness is being able to service the request independently without any requirement to remember any previous interactions.

In the example you have provided,

https://localhost:8080/UserManagement/rest/UserService/users/1

The restful service implementation that handles this request does not need to remember or know about any previous interaction with the client invoking the service.
All the information it needs to serve or process the request is provided and available in the request itself. It needs the user id, which it gets from the request URL itself and it is 1, it fetches the user details and returns the XML response.
For stateless services, if you need to change the response you would need to change the request details or the context values you pass in the request (so in addition to the URL it could also be the HTTP request headers like content type or Accepts, etc)
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
State: One of the good example of maintaining state of request is say JSP where session is created and you can store values in it. You will get to know that state is maintained say login when user visits the page. Next request server in this case will be using data stored in session or token stored in session for authentication or authorization.

Statelessness: No session of any other means is there to record whether request is first request or second. All rest services are Statelessness services and if you hit it multiple times it will treated as new request. You cannot have session kind of concept here. All responses from service will be send based on request not on any stored data as it is not there.

 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic