java - HttpRequestHandler - How to tell client to save a cookie? -
i'm in journey of making simple http server using java educational purposes. need know how instruct client save cookie identifying session id.
i've done research , stumbled upon this , this which, despite being informative , in fact introduced me whole cookiestore thing, not specify how tell client save cookie.
from i've come understand, handle method in httprequesthandlers has 3 parameter passed it:
httprequest- request along information it.httpresponse- "medium" of response should writen upon.httpcontext- ... (not sure does, tbh.)
meanwhile, of answers in links i've stated above call
response = client.execute(httppost, localcontext);, orhttpresponse response1 = httpclient.execute(method1, httpcontext);
..at point of handling. i've no idea on how 1 reference client (and execute request store cookie).
what should do? missing something?
cookie usercookie = new cookie("name","value"); usercookie.setmaxage(-1);//for session cookie usercookie.setpath("/"); response.addcookie(usercookie);//adds cookie response sent browser.
Comments
Post a Comment