• 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

statelessness rest webservice  RSS feed

 
Ranch Hand
Posts: 542
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!