When I need to update the user date which is not present in the database it should execute the first IF STATEMENT in JSP since the message is not null and userTable is set to null (It is supposed to work like that) . But when I try , it executs both IF STATEMENT .
Note
In controller code userTable object is set to null if the ID is not found so either userTable or message is null .
Controller code
@RequestMapping("updateUser")
public ModelAndView updateUser(@RequestParam int id) {
ModelAndView mav = new ModelAndView("updateUser.jsp");
UserTable userTable = userDao.findById(id).orElse(null);
if(userTable == null) {
mav.addObject("message","User didn't exist");
}else {
userDao.deleteById(id);
mav.addObject(userTable);
}
return mav;
}```
**JSP code**
```jsp
<html>
<head>
<title> Welcome to .com </title>
</head>
<body>
<h2> User information to be updated </h2>
<c:if test = "message != null">
${message}
</c:if>
<c:if test = "userTable != null">
${userTable} <br> <br>
<form action = "updateUser">
Enter ID <input type = "text" name = "id"> <br>
Enter Name <input type = "text" name = "name"> <br>
<input type="submit"> <br>
</form>
</c:if>
</body>```