error occured:-java.lang.NullPointerException
Here is my code:-
<%@ page import="java.sql.*" %>
<%
String payer = request.getParameter("payer");
String payment = request.getParameter("payment");
String date = request.getParameter("date");
String details = request.getParameter("details");
String[] vals = request.getParameterValues("all");
try{
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@172.16.2.48:1521:DIANAPRD", "difbank", "difbank");
PreparedStatement ps=conn.prepareStatement("INSERT INTO p_city VALUES (?,?,?,?,?)");
ps.setString(1,payer );
ps.setString(2,payment );
ps.setString(3,date );
for (String val : vals)
{ ps.setString(4, val);
}
ps.setString(5,details);
ps.execute();
ps.close(); %>
<html>
<center>
<body>
<b>Successfully inserted expenditure.You want to insert another expenditure pls click</b>
<a href = "C:\workspace\HouseManagement\WebContent\ExpendInf o.jsp"><b>INFORMATION FILL</b></a>
</body>
</center>
</html>
<%}
catch(Exception e)
{
out.println("error occured:-"+e);
} %>
please tell me where I hv mistaken.
Re: error occured:-java.lang.NullPointerException
Your mistake is putting Java code into a JSP.
That code should be in a servlet or, since it's all to do with DB access, in a data layer that the servlet calls.
The JSP should simply be for displaying the result forwarded on by that servlet.