0

I have this set of code to display name and status from database:

<table id="gbdb" class="table table-bordered table-striped" style="width:100%">
  <thead>
    <tr>
     <th>Name</th>
     <th>Status</th>
    </tr>
  </thead>
  <tbody>

<c:forEach items="${guestbookList}" var="guestbook">
  <tr>
    <td>${guestbook.name}</td>
    <td>${guestbook.status}</td>
    <!-- ... -->

Right now guestbook.status is returning me either 1 or 0 as stated in the database.

How do I put in an if-else check so that it will display 0 as pending and 1 as approved?

Adrien Brunelat
  • 4,492
  • 4
  • 29
  • 42
Liferayer
  • 17
  • 4

1 Answers1

1

You can try ternary operator ('?')
Syntax :- condition ? exprTrue : exprFalse

 <td> ${guestbook.status == 0 ? 'Pending' : 'Approved'} </td>
Manasi
  • 765
  • 6
  • 17
Rupesh Agrawal
  • 645
  • 8
  • 22