0
<section>
    <div class="container"> 
        <table class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
        <th>Address</th>
        <th>Function</th>
        </tr>
        </thead>
        <tbody>
            <c:forEach items="${users}" var="user" varStatus="status">
        <tr>
            <td >${status.count}</td>
            <td ><c:out value="${user.name}"></td>
            <td><c:out value="${user.email}"></td>
            <td><c:out value="${user.address}"></td>
            <td>
            <div class="btn-group">
            <button type="submit" class="btn btn-primary" onclick = "Edit()">Edit</button>
                <button type="submit" class="btn btn-primary" onclick = "Delete()">Delete</button>                              
            </div>
            </td>
        </tr>
        </c:forEach>                
        </tbody>
        </table>                    
    </div>
</section>

Here's my code. How to delete temporary data?

My sample table screenshot

Pang
  • 9,073
  • 146
  • 84
  • 117
Snow
  • 1
  • 1

2 Answers2

0

Your delete function should send a request to your servlet to delete the record. So, you should have something like this /yourServlet?{id}. Your code in the servlet should look for that {id} in the collection of users and remove it. I'm not sure for the meaning of (table without SQL), but I'm under the impression that you have sql stuff within jsp file before?

Rae Burawes
  • 842
  • 7
  • 17
  • Thank you. Table without SQL means data from table are not store in database. Temp data. – Snow Jul 08 '16 at 04:12
0

I suggest that you change the button to a hyperlink that call a servlet like this :

<a class=" btn btn-danger btn-sm " href="Deleteservlet?email=${user.email}>Delete</a>

I put user.email because it's frequently a way to identify the user you can change it with user id

and in your servlet : ( in doGet() method)

String email = request.getParameter("email");
//call a method to delete this user example deleteUser(email);

If users is an ArrayList you can find this user with a loop and then delete it

Taha
  • 894
  • 1
  • 12
  • 28