Getting cookie in servlet

后端 未结 5 1820
情话喂你
情话喂你 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:55

    I had the same problem and discovered the cause in my case was that I was using the browser built into Eclipse. This does not accept cookies. When I accessed the same JSP from chrome, it worked. Perhaps you are doing the same thing I did?

    It may also be the case that the browser you are using or your internet settings are set to reject cookies. Hope this helps you or any other visitor experiencing the same issue.

提交回复
热议问题