Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008, 03:19 PM
Member
 
Join Date: Feb 2008
Posts: 4
doflynn is on a distinguished road
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");
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-04-2008, 04:45 PM
Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 96
wsaryada is on a distinguished road
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.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-04-2008, 05:08 PM
Member
 
Join Date: Feb 2008
Posts: 4
doflynn is on a distinguished road
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();
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-04-2008, 05:14 PM
Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 96
wsaryada is on a distinguished road
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.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +3. The time now is 02:22 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org