This is my jsp code with delete button. I dont want to delete current login user. This is my jsp code with delete button. I dont want to delete current login user.
<table border="1">
<thead style="background: #0086B2;">
<tr>
<th></th>
<th>Sl No.</th>
<th>User Name</th>
<th>Phone Number</th>
<th>Email Id</th>
<th>Login Id</th>
</tr>
</thead>
<c:if test="${userList!=null}">
<c:forEach items="${userList}" var="user">
<tr>
<td><input type="checkbox" name="deleteVal"
value="${user.slNo}"></td>
<td>${user.slNo}</td>
<td>${user.userName}</td>
<td>${user.emailId}</td>
<td>${user.phoneNumber}</td>
<td>${user.loginId}</td>
</tr>
</c:forEach>
</c:if>
</table>
<br>
<table>
<tr>
<td><input type="button" value="Delete"></td>
<tr>
</table
You can do something like this:
<table border="1">
<thead style="background: #0086B2;">
<tr>
<th></th>
<th>Sl No.</th>
<th>User Name</th>
<th>Phone Number</th>
<th>Email Id</th>
<th>Login Id</th>
<th>Delete</th>
</tr>
</thead>
<c:if test="${userList!=null}">
<c:forEach items="${userList}" var="user">
<tr>
<td><input type="checkbox" name="deleteVal"
value="${user.slNo}"></td>
<td>${user.slNo}</td>
<td>${user.userName}</td>
<td>${user.emailId}</td>
<td>${user.phoneNumber}</td>
<td>${user.loginId}</td>
<c:if test="${user.slNo != (User Id from session)}">
<td><input type="button" value="Delete"
onclick="delete(${user.slNo})"></td>
</c:if>
</c:forEach>
</c:if>
</table>
Logic is that if current user ID equals the user ID in the list
, then don't show the delete button.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.