Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I pick up the session cookie in my servlet?

cookie pick servlet session
0
Posted

How do I pick up the session cookie in my servlet?

0

Within the servlet it all depends on whether this is the first request of the session or a subsequent session. If it’s a subsequent session, then it’s easy; use HttpServletRequest.getCookies() or getHeaders(“cookie”). If it’s the first request, then there is some difficulty since the session has just been created and there’s no request cookie yet; in this case, use getId() to fetch the ID string. Unfortunately, unless you were able to do a getHeaders(“cookie”), you need to come up with the name of the session ID cookie since it’s not necessarily JSESSIONID as it is on Tomcat. The somewhat unsatisifactory way that I’ve found to get around this is to force the web server to always use JSESSIONID using some manual configuration. This has worked for me on WebSphere and iPlanet.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123