Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
condition <c:when test=""> within jstl <c:forEach>

beforehand I have model.addattribute(list, 'list') in which list is a list of VOs Within each VO I have choices=[val1,val2,val3...] and in some VOs I have choices=[]

I want to make a code in which:

  1. if choice doesn't have values: text type input appears
  2. and when it has values: radio type input appears

no 2. works fine, but I'm having trouble with the condition within my when statement.

<c:when test="${empty ${one.survey_choices}}">

I have also tried

<c:when test="${empty one.survey_choices}">

but both don't work.

Here's my code:

<c:forEach items="${surveyList}" var="one">
  <tr>
    <td style="text-align: left">
      <h4 class="fw-bold text-center mt-3"></h4>
      <p class="fw-bold">${one.survey_idx}.${one.survey_question}</p>
      <div class="form-check mb-2">
        <c:choose>
          <c:when test="${empty ${one.survey_choices}}"> <!-- ERROR!!! -->
            <p>success!!!</p>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon1">${one.survey_idx}.${one.survey_question}</span>
              </div>
              <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
            </div>
          </c:when>
          <c:otherwise>
            <c:forTokens items="${one.survey_choices}" var="choice" delims=",">
              <input class="form-check-input" type="radio" name="exampleForm" id="radioExample1" />
              <label class="form-check-label" for="radioExample1">
                <c:out value="${choice}" />
              </label>
            </c:forTokens>
          </c:otherwise>
        </c:choose>
      </div>
    </td>
  </tr>
</c:forEach>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!