Code:
<%
String firstName = request.getParameter("txtName");
String lastName = request.getParameter("txtLastName");
String gender = request.getParameter("listGender");
String address = request.getParameter("txtAdd");
String country = request.getParameter("txtCountry");
String contact = request.getParameter("txtContact");
String email = request.getParameter("txtEmailID");
String userName = request.getParameter("txtUname");
String password = request.getParameter("txtPass");
Connection con =null;
try {
//Driver Loading
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Or any other driver
//Defie the connection URL
String url = "jdbc:odbc:cmobs";
//Establish the connection
con = DriverManager.getConnection(url);
//create the statement
Statement st = con.createStatement();
//Step 6: Execute the query
String sql = "insert into Info(FIRSTNAME,LASTNAME,GENDER,DOB,COUNTRY,ADDRESS,,CONTACT,EMAIL,USERNAME,PASSWORD) VALUES('"+firstName+"','"+lastName+"','"+gender+"','"+country+"','"+address+"','"+email+"','"+userName+"','"+password+"')";
st.executeUpdate(sql);
}
catch(Exception ex)
{
//out.println("Unable to load the driver class!"+ ex);
con.close();
}
%>
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /DB.jsp at line 43
40: catch(Exception ex)
41: {
42: //out.println("Unable to load the driver class!"+ ex);
43: con.close();
44: }
45:
46:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
root cause
java.lang.NullPointerException
org.apache.jsp.DB_jsp._jspService(DB_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
I will be thankful to all of you if you help me and edit my codeto perfection plzz help..!!!


