bob90937 bob90937 - 1 year ago 97
Java Question

how to change the scriplet to JSTL display string array

how to change the scriplet to JSTL

<%String sentenceArray[] = (String[])request.getAttribute("displaySentenceArray"); %>

<% for (int i=0; i< sentenceArray.length;i++){ %>

<p> The Result IS : <%=sentenceArray[i] %> </p>

<%} %>

I am new to JSTL

Answer Source

Your JSTL should look like this

    <c:forEach var="sentence" items="${requestScope.displaySentenceArray}" >
        <p> The Result IS   :<c:out value="${sentence}"></c:out></p>

Here requestScope.displaySentenceArray will get the whole array from request.'sentence'will be a single element of array, tag will iterate the array and will print the element to JSP.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download