Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- txt = txt + "<td class="pull-right">" + "<form name="form1" method="get" action="SetTrue">" +
- "<input type="hidden" name="id" value="" + nn[0].firstChild.nodeValue + ""/>"
- + "<button type="submit" class="btn btn-link glyphicon glyphicon-star"></button>"
- + "</form>" + "</td>";
- ...
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- HttpSession session = request.getSession();
- response.setContentType("text/html;");
- PrintWriter out = response.getWriter();
- Integer UserID = (Integer)session.getAttribute("iduser");
- String errorMsg = null;
- String successMsg = null;
- try {
- ConnectionManager conn = new ConnectionManager();
- Connection connection = conn.getConnection();
- PreparedStatement statement = null;
- String string_id = request.getParameter("id");
- int id = Integer.parseInt(string_id);
- boolean set_true = true;
- String update = "UPDATE Table SET Attribute=? WHERE ID=? AND UserID=?";
- statement = connection.prepareStatement(update);
- statement.setBoolean(1, set_true);
- statement.setInt(2, id);
- statement.setInt(3, UserID);
- int num = statement.executeUpdate();
- if (num > 0) {
- successMsg = "OK";
- out.println(successMsg);
- RequestDispatcher reqDisp = getServletContext().getRequestDispatcher("/Welcome.jsp");
- reqDisp.forward(request, response);
- }
- else {
- errorMsg = "Error";
- session.setAttribute("error", errorMsg);
- RequestDispatcher reqDisp = getServletContext().getRequestDispatcher("/Welcome.jsp");
- reqDisp.forward(request, response);
- }
- connection.close();
- statement.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- ...
- $("#form1").submit(function(){
- $.ajax({
- type : form.attr('method'),
- url : form.attr('action'),
- success : function(data) {
- alert(data);
- }
- });
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement