I'm in a journey of making a simple HTTP
server using Java for educational purposes. I need to know how to instruct a client to save a cookie for identifying its session ID.
I've done my research and stumbled upon this and this which, despite being greatly informative and in fact introduced me to the whole CookieStore
thing, does not really specify how to tell the client to save a cookie.
From what I've come to understand, the handle
method in HttpRequestHandlers
has only three parameter passed to it:
HttpRequest
- the request itself along with some information about it.HttpResponse
- the "medium" as of where the response should be writen upon.HttpContext
- ... (Not really sure what it does, TBH.)
Meanwhile, all of the answers in the links I've stated above would call
response = client.execute(httppost, localContext);
, orHttpResponse response1 = httpClient.execute(method1, httpContext);
..at some point of the handling. I've no idea on how one could get a reference to the client (and thus execute the request to store the cookie).
What should I do? Am I missing something?