1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nullpointer exception

Discussion in 'JSP' started by Ziaur Rahman, Aug 20, 2010.

  1. Ziaur Rahman

    Ziaur Rahman New Member

    Joined:
    Oct 22, 2006
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune
    I am new to java.when running registration.jsp page getting error
    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
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


    root cause

    java.lang.NullPointerException
    org.apache.jsp.registration_jsp._jspService(org.apache.jsp.registration_jsp:95)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.


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

    Apache Tomcat/5.5.9
    =====================
    My page is as:-
    Registration.jsp
    =====================
    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <jsp:directive.page import="com.ziaur.dataAccessBean"/>
    <jsp:directive.page import="java.sql.ResultSet"/>
    
       its contain some text box
    my script let are
    <form action="userregst.jsp" method="post" name="contactForm">
     	<%
     	int registration_id=0;
     	dataAccessBean ob=new dataAccessBean();
     	ResultSet rs=ob.executeQuery("Select * from registeration");
     	if(rs.next())
    	{
    		 
    		 	if(rs.next())
    		 	{
    		 		 registration_id=rs.getInt(1)+1;
    		 	}
    	}	 	
    		 	else
    			{
    			 registration_id=1;
    			}
    	 		
     	 %> 
    
    ========================================
    and my java class dataAccessBean.java is as======
    ================================
    Code:
    package com.ziaur;
    import java.sql.*;
    
    public class dataAccessBean {
    	private static String driver="sun.jdbc.odbc.jdbcodbcDriver";
    	private  static String  database = "F:\\globus.mdb"; 
    	private static String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+database+";DriverID=22;READONLY=false";  
    	private static String uid="";
    	private static String pass="";
    	Connection con=null;
    	Statement st=null;
    	
    	
    	public dataAccessBean()
    	{
    		try{
    			Class.forName(driver);
    			con=DriverManager.getConnection(url,uid,pass);
    			st=con.createStatement();
    		}
    		catch(Exception e)
    		{
    			
    		}
    	}
    	
    	
    	public ResultSet executeQuery(String qry)
    	{
    		ResultSet rs=null;
    		try
    		{
    			System.out.println(qry);
    			rs=st.executeQuery(qry);
    			
    		}
    		catch (Exception e) 
    		{
    
    			System.out.println("data get from bean"+e.getMessage());
    		}
    		return rs;
    		
    	}
    	public int executeUpdate(String qry)
    	{
    		int i=0;
    		try{
    			i=st.executeUpdate(qry);
    			System.out.println(i);
    		}
    		catch(Exception e)
    		{
    			System.out.println("Exception in Query"+e.getMessage());
    		}
    		return i;
    		
    	}
    
    }


    please help me why i am getting error...kindly help me to solve it...
     
    Last edited by a moderator: Aug 21, 2010

Share This Page