Данные не обновляются
я написал бизнес-логику в сервлете для обновления данных html-таблицы с помощью jsp.
я даю тебе код.:
BOQServlet
package com.mvc.controller; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mvc.util.DBConnection; @WebServlet("/BoqServlet") public class BoqServlet extends HttpServlet{ public static Connection connect=null; public static Statement stmt=null; public ResultSet rst = null; int status=0; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub PrintWriter out = resp.getWriter(); try { String Id; String HSN_CODE,HSNCODE_CONFIRMATION,gst_Rate,GST_RATE_Confirmation,ITEM_DESC,_qty,_Unit,P,_W,V; HSN_CODE =req.getParameter("_hsn_Code"); HSNCODE_CONFIRMATION =req.getParameter("_isHSN_CodeConfirmed"); gst_Rate =req.getParameter("_gst_RATE"); GST_RATE_Confirmation =req.getParameter("GST_rate_Confirmation"); ITEM_DESC=req.getParameter("_ItemDesc"); _Unit =req.getParameter("_unit_"); _qty =req.getParameter("_QTy"); P = req.getParameter("_p"); _W = req.getParameter("__w"); V =req.getParameter("__V"); Id = req.getParameter("_id"); //this.doGet(req, resp); connect = DBConnection.createConnection(); stmt = connect.createStatement(); String sql = "update boq set hsn_Code='"+HSN_CODE+"', is_hsnConfirmed='"+HSNCODE_CONFIRMATION+"',gst_rate='"+gst_Rate+"',is_gstRate_confirmed='"+GST_RATE_Confirmation+"',item_Description='"+ITEM_DESC+"',Unit="+_Unit+"',Qty='"+_qty+"', p='"+P+"',w='"+_W+"',v='"+V+"'_where id="+Id+""; status = stmt.executeUpdate(sql); if(status>0) { out.println("row has been updated successfully"); req.getRequestDispatcher("/jkpddReport.jsp").forward(req, resp); } else { resp.sendRedirect("/Error.jsp"); } } catch (SQLException e) { // TODO: handle exception } } }
сметный расчет-форма.ОСП
<%@page import="java.sql.SQLException"%> <%@page import="java.sql.ResultSet"%> <%@page import="java.sql.Statement"%> <%@page import="com.mvc.util.DBConnection"%> <%@page import="java.sql.Connection"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Edit BOQ</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <title>Update BOQ</title> </head> <body> <%!String ID; String _HsnCode, _ISHsnCodeConfirmed, GST_RATE, IS_GST_RATECONFIRMED,item_desc,UNIT,_QTY,_P,W,_V; %> <% try ///ye sound band karo yar....bhai ye _id kya h....form page na { //yea ID = request.getParameter("_id"); Connection con = DBConnection.createConnection(); Statement stmt = con.createStatement(); ResultSet rst = stmt.executeQuery("select * from boq where id="+ID+""); if(rst.next()) { _HsnCode = rst.getString("hsn_Code"); _ISHsnCodeConfirmed = rst.getString("is_hsnConfirmed"); GST_RATE = rst.getString("gst_rate"); IS_GST_RATECONFIRMED= rst.getString("is_gstRate_confirmed"); item_desc = rst.getString("item_Description"); UNIT = rst.getString("Unit"); _QTY = rst.getString("Qty"); _P = rst.getString("p"); W = rst.getString("w"); _V = rst.getString("v"); ID = rst.getString("id"); out.println(rst.getInt("id")); } } catch(SQLException e) { out.println(e); response.sendRedirect("/error.jsp"); } %> <center> <div class="container"> <center> <h2>Update</h2> </center><hr> <form action="BoqServlet" method="GET"> <table class="table table-bordered" style="width:60%; "> <thead> <tr> <th colspan="2"><center>BOQ Update form</center></th> </tr> </thead> <tbody> <input type="hidden" name="_id" value="<%=ID%>"/> <tr> <td>Hsn Code</td> <td><input type="text" name="_hsn_Code" required="required" class="form-control" value="<%= _HsnCode %>"/></td> </tr> <tr> <td> HSN code confirmation </td> <td><input type="text" name="_isHSN_CodeConfirmed" required="required" class="form-control" value="<%=_ISHsnCodeConfirmed %>"/></td> </tr> <tr> <td>GST Rate</td> <td><input type="text" name="_gst_RATE" required="required" class="form-control" value="<%=GST_RATE%>"/></td> </tr> <tr> <td>GST Rate Confirmation</td> <td><input type="text" name="GST_rate_Confirmation" required="required" class="form-control" value="<%=IS_GST_RATECONFIRMED %>"/></td> </tr> <tr> <td>Item Description</td> <td><input type="text" name="_ItemDesc" required="required" class="form-control" value="<%=item_desc %>"/></td> </tr> <tr> <td>Units</td> <td><input type="text" name="_unit_" required="required" class="form-control" value="<%=UNIT %>"/></td> </tr> <tr> <td>Quantity</td> <td><input type="text" name="_QTy" required="required" class="form-control" value="<%=_QTY%>"/></td> </tr> <tr> <td>P</td> <td><input type="text" name="_p" required="required" class="form-control" value="<%=_P%>"/></td> </tr> <tr> <td>W</td> <td><input type="text" name="__w" required="required" class="form-control" value=<%=W %> "/></td> </tr> <tr> <td>V</td> <td><input type="text" name="__V" required="required" class="form-control" value="<%=_V%>"/></td> </tr> <tr> <td><input type="reset" value="Reset" class="btn btn-info"/></td> <td><input type="submit" name="update" value="Update" class="btn btn-primary"/></td> </tr> </tbody> </table> </form> </div> </center> <center> <a href="jkpddReport.jsp">View BOQ</a> </center> </body> </html>
Когда я вставляю данные во все текстовое поле. он показывает только пустую страницу, если данные не обновляются.
Что я уже пробовал:
я отладил приложение, но не могу получить никакой подсказки