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);, or
  • httpresponse 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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -