Review the code below. It fetches all the cookies and displays the contents.
Java Code:
import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {
  public void doPost
    (HttpServletRequest req, HttpServletResponse res) {
     Cookie[] theCookies = request.getCookies();
     if (theCookies != null) {
        java.io.PrintWriter out = res.getWriter();
        for (int i =0; i< cookies.length; i++) {
           Cookie aCookie = theCookies[i];
           out.println 
             ("Name : " + aCookie.getName() 
               + " Value: " + aCookie.getValue());
           }
        }
    }
    
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    doPost(req, res);
    }
    
}