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 ;
}
}
le servlet tente d'appeler cette classe comme celui-ciexception NullPointer lors de l'initialisation d'une classe servlet
mstLeastCountEdit ref1 = new mstLeastCountEdit();
et il émet une exception nullpointer. je suis encore bâclée sur la classe, et ceci est un vieux code développé 10 ans en arrière, tout aidera?
Si vous voulez une réponse décente, incluez la pile. –
Et une indication de quelle ligne est laquelle. –