Getting cookie in servlet

后端 未结 5 1773
情话喂你
情话喂你 2021-01-04 05:47

I\'m trying to get cookie in servlet using

Cookie[] cookie = request.getCookies();

but cookie is always null.

5条回答
  •  北海茫月
    2021-01-04 05:52

    firstly ,you should create a cookie,and then add to response

    Cookie cookie = new Cookie(name,value);
    response.addCookie(cookie);
    

提交回复
热议问题