How to set Cookies in Java? -


i writing program login university web site part of project. problem have how set cookies , let browser enable these cookies, code below , gives me nullpoiterexception, did wrong can me:

    (string cookie : this.cookies) {         conn.addrequestproperty("cookie", cookie.split(";", 1)[0]);     } 

part of servlet, how set cookie.

protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {     printwriter out = response.getwriter();     string ksywa = request.getparameter("ksywa");     out.print("twoje nazwisko " + ksywa);     cookie cookie = new cookie("pseudonim", ksywa);     cookie.setmaxage(60*60);     response.addcookie(cookie); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -