Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

statelessness rest webservice

Ranch Hand
Posts: 542
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i was reading as below

what is the meaning of below

Consider the following URL −


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.


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
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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,


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)
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.

Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic