Results 1 to 4 of 4
  1. #1
    doflynn is offline Member
    Join Date
    Feb 2008
    Posts
    4
    Rep Power
    0

    Default Concurring Java Problem..Please Help

    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");
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default

    Quote Originally Posted by doflynn View Post
    root cause

    java.lang.NullPointerException
    hospital.NurseDao.getNurse(NurseDao.java:324)
    Base on the error message above can you tell us what is on the 324 line of your NurseDao.java, because this line cause the NPE in your program.

  3. #3
    doflynn is offline Member
    Join Date
    Feb 2008
    Posts
    4
    Rep Power
    0

    Default

    Thanks a million for your reply.

    Line 324 consisted of this block of code:

    try{


    DBConnectionManager manager = DBConnectionManager.getInstance();
    con = manager.getConnection("hospitaldb");

    Line 324: Statement stmt = con.createStatement();
    ResultSet results = stmt.executeQuery ("Select * from Nurse where surname = '" + strUN + "'");


    while (results.next()){
    Nurse = new Nurse();
    Nurse.setStaffId(results.getInt("NurseID"));
    Nurse.setWardId(results.getInt("WardId"));
    Nurse.setFirstName(results.getString("FirstName")) ;
    Nurse.setSurname(results.getString("Surname"));
    Nurse.setAddress(results.getString("Address"));
    Nurse.setContactNumber(results.getString("ContactN umber"));


    }

    stmt.close();
    con.close();

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default

    Ok then. The only thing that could throw the NPE is the connection object. Have you check whether the DBConnectionManager class returning a valid connection object? If it fails to create the connection object, the connection is null, and when you try to create an instance of statement from it and NPE is thrown.

Similar Threads

  1. Concurring Java Problem...PLease Please Help
    By doflynn in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-14-2008, 09:46 PM
  2. Concurring Java Problem
    By doflynn in forum NetBeans
    Replies: 0
    Last Post: 02-04-2008, 02:20 PM
  3. Problem in java
    By saytri in forum New To Java
    Replies: 4
    Last Post: 01-16-2008, 10:09 PM
  4. JAVA if problem
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-25-2007, 07:58 PM
  5. java SE 6 problem
    By techlance in forum Java Applets
    Replies: 1
    Last Post: 06-28-2007, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •