Hi All'
I am Charu. I have a this type of error for saving data in database through user input.
Error is as below:

A Servlet Exception Has Occurred
java.lang.NullPointerException
at org.apache.jsp.sample$jsp._jspService(sample$jsp.j ava:97)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:1264)
at org.apache.jasper.servlet.JspServlet$JspServletWra pper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:1264)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:215)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invok e(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2366)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:566)
at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNe xt(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.p rocess(HttpProcessor.java:1005)
at org.apache.catalina.connector.http.HttpProcessor.r un(HttpProcessor.java:1098)
at java.lang.Thread.run(Unknown Source)



And my jsp code as below

<%@ page language="java" import="java.sql.*" %>
<%@ page import ="java.lang.*" %>

<% Connection con = null; %>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sample1 ","","");
System.out.println(con);
}
catch(ClassNotFoundException e)
{
System.out.println("Database Driver Not Found");
System.out.println(e.toString());
}
catch(Exception e)
{
System.out.println("Unknown");
System.out.println(e.toString());
}

%>

<%
String sql="insert into sample1 values(?,?)";
PreparedStatement st = con.prepareStatement(sql);


String name= request.getParameter("T1");
int age = Integer.parseInt(request.getParameter("T2"));


st.setString(1,name);

st.setInt(2,age);



st.executeUpdate();

%>
Record Added!!!!!


Please help me for solving my problem.


Regards
Charu.