Doesn't the author mean, "the request and its attributes are no longer available to the server?" The client is the origination endpoint.
The request (and its attributes) as Java objects are handled in the server, but the client is who sent the request. That's why author may refer that the request belongs to client and not to server. After processing the request, it has no use so is dropped (HTTP concept), but in Java Web Server, the ServletRequest
object (usually handled as a HttpServletRequest
) that resides in the server will no longer be available, so it will be garbage collected.
The garbage collector cleans-up the heap memory available to the server JVM. The browser (client) doesn't use the heap.
Answered in the last part of the 1st answer.
The request attributes are integrated into the HttpServletRequest object by the web container.
You confuse the attributes from the HTTP request (GET, POST, etc) and the HttpServletRequest
attributes that can be accessed through HttpServletRequest#getAttribute(String)
. You can access to the HTTP request attributes like character encoding, content type and request parameters by using the functions in the provided links, you can also know other HTTP attributes by using the other functions in the HttpServletRequest
interface.
When do the HttpServletRequest and HttpServletResponse objects get garbage collected?
After the HTTP response is committed and finished. Please refer to How do servlets work? Instantiation, session variables and multithreading
Isn't the lifecycle of the HTTP request over at the moment the HTTP response is sent back to the client? The lifecycle doesn't include what the client does with the response?
Once the response gets to the client, it's up to the client to decide what to do with it. Note that you can have: ajax requests, full HTTP requests, resource requests (for JS, CSS and images, for example), portlet Requests...