When I run my java application this error keeps coming up when trying to log in. Yer help would be much appreciated

HTTP Status 500 -
--------------------------------------------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: Exception in JSP: /HeadNPass.jsp:19

16:
17:
18: NurseDao da = new NurseDao();
19: Nurse n = da.getNurse(userName);
20:
21: if(n != null)
22: {

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:368)


root cause

java.lang.NullPointerException
hospital.NurseDao.getNurse(NurseDao.java:324)
org.apache.jsp.HeadNPass_jsp._jspService(HeadNPass _jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:368)




--------------------------------------------------------------------------------

The code is as follows:


String userName = request.getParameter("username");
String password = request.getParameter("password");


if ((userName != null) && (password != null)){


NurseDao da = new NurseDao();
Nurse n = da.getNurse(userName);

if(n != null)
{
int pw = Integer.parseInt(password);
if(n.getStaffId() == pw)
{
request.getSession(true).setAttribute("HEADNURSE", n);
response.sendRedirect("HeadNurse.jsp");
}
else
{
response.sendRedirect("error.jsp");
}
}
else
{
response.sendRedirect("error.jsp");
}