String username = request.getParameter("username");
String userAgent = request.getHeader("User-Agent");
Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals("sessionId")) { // do something with cookie value } } }This retrieves all the cookies from the HTTP request, and then loops through them to find a specific cookie by its name. The javax.servlet.http package is part of the Java Servlet API, which provides a framework for building web applications in Java.