iam getting an NullPointerException while i run my jsp page.
Here is my code,I dont understand where am i doing a mistake.<%@ page info="Company Master" import="java.sql.*" session="true" %>
<html>
<head>
<script language="javascript">
function f1()
{
var x=document.company.code.value.toUpperCase();
if(x!=null)
document.company.code.value=x;
}
</script>
</head>
<body bgcolor="yellow"> <font color="red"></font>
<h2><center>Company Master </center></h2>
<form name="company">
<pre>
Code : <input type=text name="code">
Name : <input type=text name="name">
Address : <textarea name="add" rows=5 cols=30></textarea>
Contact Person : <input type=text name="contact">
Phone : <input type=text name="ph">
Mail Id : <input type=text name="mail">
<input type=submit name="sub" value="Insert"> <input type=submit name="sub" value="Query">
<input type=submit name="sub" value="Clear"><input type=submit name="sub" value="Back">
</pre>
</form>
<%!
String code,name,add,contact,ph,mail,butt;
String code1=" ",name1=" ",add1=" ",contact1=" ",ph1=" ",mail1=" ",xx1=" ";
Connection con;
ResultSet rs;
public void jspInit()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:plk","scott","tiger");
}catch(Exception e)
{
System.out.println("error in Connection"+e);
}
}
%>
<%
PreparedStatement ps = con.prepareStatement("insert into Company values(?,?,?,?,?,?)");
PreparedStatement ps1 = con.prepareStatement("select * from Company where upper(code)=?");
code=request.getParameter("code");
name=request.getParameter("name");
add=request.getParameter("add");
contact=request.getParameter("contact");
ph=request.getParameter("ph");
int uph=0;
try
{
uph=Integer.parseInt(ph);
}catch(NumberFormatException e)
{
System.out.println(e.getMessage());
}
mail=request.getParameter("mail");
butt=request.getParameter("sub");
if(code!=null && name!=null && add!=null && butt.equals("Insert"))
{
try
{
ps.setString(1,code);
ps.setString(2,name);
ps.setString(3,add);
ps.setString(4,contact);
ps.setInt(5,uph);
ps.setString(6,mail);
int i=ps.executeUpdate();
System.out.println(i+"row is inserted");
}
catch(Exception e)
{
%>
<jsp:forward page="Error.html" />
<%
}
}
if(code!=null && butt.equals("Query"))
{
try
{
ps1.setString(1,code.toUpperCase());
rs=ps1.executeQuery();
System.out.println("query"+rs.next());
code1=rs.getString(1);
name1=rs.getString(2);
add1=rs.getString(3);
contact1=rs.getString(4);
ph1=rs.getString(5);
mail1=rs.getString(6);
}
catch(Exception e)
{
%>
<jsp:forward page="Error.html" />
<%
}
}
if(code!=null && butt.equals("Clear"))
{
code1="";
name1="";
add1="";
contact1="";
ph1="";
mail1="";
}
if( butt.equals("Back"))
{
%>
<a href="http://localhost:8080/Admin.html"></a>
<%
}
%>
</body>
</html>

