From the course: Java EE: Servlets and JavaServer Pages (JSP)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using cookies

Using cookies

From the course: Java EE: Servlets and JavaServer Pages (JSP)

Start my 1-month free trial

Using cookies

- [Instructor] So now we will implement the demo for cookies. We've already seen what we are going to do. So this is our searchResults.jsp where we had displayed all the products. And that's the form tag. So what we are going to do is, whenever the user clicks on add to cart button we are going to reach a servlet. We are going to set up the entire session management using cookies. And then, we work it out to see whether the changes take effect. Okay, so the first step for this is we have to write a servlet class for session management. So, if you see, there is this products servlet class that I've already written out in the form of a template. Of course this extends the HttpServlet and I've annotated it with a URL pattern of addProducts on line number 11. The next step will be to get the HTTPSession object on the HTTPServletRequest API. So, as we discussed in the previous video, if we need to entirely set up the session, the session ID, and it has to get exchanged between the client…

Contents