user2470075
user2470075

Reputation: 169

<JSP> How to display one data from multiple row

I have a query that gives me 3 data under 1 parameter. Following is query.

Query

SELECT 
      VQ_CD       
    , FILE_NM
FROM 
    TB_POT_ECD_VQ_INFO
WHERE        
    PRCS_SNO = '1'

When I run the query, the data I get is..

PRCS_SNO     VQ_CD          FILE_NM    

 1            500K             A
 1           1000K             B
 1            2000K            C

And in JSP page, I want to display all three data. What I did in JSP is this. Oh, table is being called encVqList.

JSP

    <td class="typeFD bgN"">
    <c:set var="V500K" value="" />
        <c:forEach var="encVqList" items="${encVqList}" >
            <input type="text" id="500K" name="500K" value="<c:out value="${encVqList.fileNm}" />"/>
    </c:forEach>

    <td class="typeFD bgN"">
    <c:set var="V1000K" value="" />
        <c:forEach var="encVqList" items="${encVqList}" >
            <input type="text" id="1000K" name="1000K" value="<c:out value="${encVqList.fileNm}" />"/>
    </c:forEach>

    <td class="typeFD bgN"">
    <c:set var="V2000K" value="" />
        <c:forEach var="encVqList" items="${encVqList}" >
            <input type="text" id="2000K" name="2000K" value="<c:out value="${encVqList.fileNm}" />"/>
    </c:forEach>

And did the same thign for 1000K and 2000K. But it doesn't work. I think I should distinguish each input box does not recognize which one since it has 3 data under 1 same parameter. So can anyone help?

Upvotes: 0

Views: 678

Answers (1)

LHA
LHA

Reputation: 9655

<td class="typeFD bgN"">
    <c:forEach var="encVqList" items="${encVqList}" >
        <c:choose>
            <c:when test="${encVqList.VQ_CD eq '500K'}">
                <input type="text" id="500K" name="500K" value="<c:out value='${encVqList.fileNm}' />" />
            </c:when>
            <c:when test="${encVqList.VQ_CD eq 'V1000K'}">
                <input type="text" id="1000K" name="1000K" value="<c:out value='${encVqList.fileNm}' />" />
            </c:when>
            <c:otherwise>
                <input type="text" id="2000K" name="2000K" value="<c:out value='${encVqList.fileNm}' />" />
            <c:otherwise>
        </c:choose>
    </c:forEach>
</td>

Upvotes: 1

Related Questions