NullPointerException at: int start = Math.max(chat.first, chat.last-10);
<p>I have the following Java code in a JSP:</p>

<pre><code>21:     ChatState chat = (ChatState)application.getAttribute(ChatConstants.APP_STATE);
22:     // assert(chat != null);
23: 
24:     int start = Math.max(chat.first, chat.last-10);
25:     for (int i=start; i&lt;chat.last; i++) {
26:     out.println(i + "User Says: " + chat.chat.get(i));
27:     }
</code></pre>

<p>Line 24 throws the following exception:</p>

<pre><code>java.lang.NullPointerException
    org.apache.jsp.chat_jsp._jspService(chat_jsp.java:77)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
</code></pre>
