Erro ao tentar carregar um cookie

Bom, a ideia é a seguinte. O arquivo index.jsp faria um teste se existe o cookie chamado “locadora”, caso exista ele irá colocar o nome do login já no campo do usuário.
Porem tá dando um erro na localização do cookie.

Sou usuário linux (debian).

O index.jsp

<HTML>
<HEAD>
<TITLE>Locadora Allvideo</TITLE>
</HEAD>
<BODY>
  <FORM ACTION="valida.jsp" method="post">
    <p>Usuario:</p>
    <%
      Cookie cookie []=request.getCookies();
      Boolean achou=false;
      String usr=null;
      for(int i=0;i<cookie.length;i++){
        if(cookie[i].getName().equals("locadora")){
          achou=true;
          usr=cookie[i].getValue();
        } 
      }  
      if(achou){
      %>
        <INPUT TYPE="text" SIZE="20" NAME="usuario" VALUE="<%=usr%>">
      <%
      }
      else {
      %>
        <INPUT TYPE="text" SIZE="20" NAME="usuario">
      <%
      }
      %>
    <p>Senha:</p>
    <INPUT TYPE="password" SIZE="8" NAME="senha">
    <p>Gostaria de salvar o login>
    <INPUT TYPE="checkbox" NAME="salvasenha" VALUE="sim"></p>
    <INPUT TYPE="submit" name="entra" VALUE="Logar">
  </form>
</BODY>
</THML>

o Erro

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 17

14:       Cookie cookie []=request.getCookies();
15:       Boolean achou=false;
16:       String usr=null;
17:       for(int i=0;i<=cookie.length;i++){
18:         if(cookie[i].getName().equals("locadora")){
19:           achou=true;
20:           usr=cookie[i].getValue();


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.NullPointerException
	org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Obrigado.