
try
{
con=DaoPack.createConnection();
}
catch(Exception e)
{
e.printStackTrace();
}
if(request.getParameter("addproduct")!=null)
{
ProductBean bean=new ProductBean();
ProductServices service=new ProductServices();
bean.setProductName(request.getParameter("productName"));
bean.setDescription(request.getParameter("desc"));
bean.setFeatures(request.getParameter("features"));
bean.setPrice(request.getParameter("price"));
bean.setQuantity(request.getParameter("quantity"));
bean.setEligibility(request.getParameter("eligibility"));
bean.setThresholdLimit(request.getParameter("thresholdLimit"));
bean.setColorCode("green");
boolean chk=false;
try
{
chk=service.addProduct(bean, con);
response.sendRedirect("adding_productmodel.jsp");
con.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
if(chk)
{
RequestDispatcher rd=request.getRequestDispatcher("adding_productmodel.jsp");
rd.forward(request,response);
}
}
if(request.getParameter("updateproduct")!=null)
{
ProductServices service=new ProductServices();
ProductBean bean = new ProductBean();
bean.setProductName(request.getParameter("productName"));
bean.setDescription(request.getParameter("desc"));
bean.setFeatures(request.getParameter("features"));
bean.setPrice(request.getParameter("price"));
bean.setQuantity(request.getParameter("quantity"));
bean.setEligibility(request.getParameter("eligibility"));
bean.setThresholdLimit(request.getParameter("thresholdLimit"));
try{
service.updateProduct(bean, con);
response.sendRedirect("updating_productmodel.jsp");
}
catch(SQLException E)
{
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.