初体験Javaサーブレットという本のソースを打ち込むとエラーが出るんですが。。2つ打ち込んだところ、2箇所で同じ実行時エラーがでます。ご教授ください。

まず1つ目のソースは

public class Lesson09Ex extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

response.setContentType("text/html; charset=Windows-31J");
PrintWriter pw = response.getWriter();

pw.println("<html><head><title>クッキーチェック</title></head><body><br><br><center><br><br>");

Cookie[] allCookies = request.getCookies(); 
if (allCookies.length == 0) { ←ここでエラーとなります
////////////////以下省略します。