class mstLeastCountEdit {
mstLeastCount reff;
HttpServletRequest request;
HttpServletResponse response;
String msg = "";
String LcDesc="";
int i = 0;
int noOfRows = 0;
HttpSession session=request.getSession(true);
Integer ccode=(Integer) session.getAttribute("companycode");
void updateEdit(mstLeastCount reff,HttpServletRequest request, HttpServletResponse response, int k)
throws ServletException,IOException,IllegalStateException {
int j = k;
this.reff=reff;
this.request=request;
this.response=response;
try{
noOfRows = Integer.parseInt(request.getParameter("noOfRows"));
String chkboxVal="";
for(i=j;i<=noOfRows;i++) {
if((request.getParameter("chk_select"+i))==null) {
chkboxVal="notticked";
}//if for checked closed
else {
chkboxVal=request.getParameter("chk_select"+i);
if(chkboxVal.equals("ticked")) {
String LcId=request.getParameter("txtLcId"+i);
String LcDesc=request.getParameter("txtLcDesc"+i);
LcDesc=LcDesc.trim();
String Rec_Status=request.getParameter("RecStatus"+i);
Statement st=reff.con.createStatement();
String qu="xxxxxxxxxxxxxxxxx";
st.executeUpdate(qu);
}//if chkbox closed
}//else checked closed
//j+=1;
}//For Loop Closed
} catch(SQLException sql) {
request.setAttribute("error", ge+" General e Exception");
reff.getServletConfig().getServletContext().getRequestDispatcher("/errjsp.jsp").forward(request,response);
} catch(Exception ge) {
request.setAttribute("error", ge+" General e Exception");
reff.getServletConfig().getServletContext().getRequestDispatcher("/errjsp.jsp").forward(request,response);
}
ResultSet rs1 = null;
try {
Statement st1 = reff.con.createStatement();
rs1 = st1.executeQuery("Select * from xxxx");
ResultSetMetaData rsm = rs1.getMetaData();
int col_Count = rsm.getColumnCount();
Vector vrow = new Vector();
while(rs1.next()) {
Vector vcol = new Vector();
for(int i=1;i<=col_Count;i++) {
vcol.addElement(rs1.getObject(i));
}
vrow.addElement(vcol);
} //while loop closed
request.setAttribute("vrow",vrow);
request.setAttribute("msg",msg);
reff.getServletConfig().getServletContext().getRequestDispatcher("/xxx.jsp").forward(request,response);
}catch(SQLException sqldel){}
return ;
}
}
the servlet is trying to call this class like this
mstLeastCountEdit ref1 = new mstLeastCountEdit();
and it throws nullpointer exception. i am still sloppy on the class , and this is a old code developed 10 years back, any will help ??