/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String id = request.getParameter("id"); String fName = request.getParameter("fName"); String lName = request.getParameter("lName"); Coach c = new Coach(); c.setId(id); c.setfName(fName); c.setlName(lName); updateCoachQuery uq = new updateCoachQuery("grocery", "root", "General1"); uq.doUpdate(c); readCoachQuery rq = new readCoachQuery("project", "root", "General1"); rq.doRead(id); String table = rq.getHTMLTable(); request.setAttribute("table", table); String url = "/coach.jsp"; RequestDispatcher dispatcher = request.getRequestDispatcher(url); dispatcher.forward(request, response); }
public String getHTMLTable() { String table = ""; table += "<table border=1>"; try { while (this.results.next()) { Coach c = new Coach(); c.setId(this.results.getString("coachID")); c.setfName(this.results.getString("coachFname")); c.setlName(this.results.getString("coachLname")); table += "<tr>"; table += "<td>"; table += c.getId(); table += "</td>"; table += "<td>"; table += c.getfName(); table += "</td>"; table += "<td>"; table += c.getlName(); table += "</td>"; table += "<td>"; table += "<a href=updateCoachForm?id=" + c.getId() + " >update</a> <a href=deleteCoach?id=" + c.getId() + " >delete</a>"; table += "</td>"; table += "</tr>"; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } table += "</table>"; return table; }