-2

Is it possible to loop vertically ? I want to display in JSP by using JSTL foreach . The value is date which is retrieved from database.

Normally looping will be like this :

<td>12-12-2011</td>
<td>12-12-2011</td>
<td>12-12-2011</td>
<td>12-12-2011</td>

But now I want to display the data like this way :

<td>12-12-2011</td> <td>12-12-2011</td> <td>12-12-2011</td> <td>12-12-2011</td>
crchin
  • 9,473
  • 6
  • 22
  • 28
  • The browser doesn't care when it's output on the screen. They're all tags..? – Deco Feb 04 '12 at 08:35
  • These data are displayed in a table and in a same row. – crchin Feb 04 '12 at 08:37
  • Because there's no sense in trying to put your html like that since the browser doesn't care how it is formatted: it will render the elements horizontally. – Kurt Du Bois Feb 04 '12 at 09:09
  • 1
    I think it would be more helpful if you reframe your question to *"How to remove whitespace from JSP-generated HTML output?"* This is a way more useful question (which has been asked *and answered* here several times before though). – BalusC Feb 04 '12 at 14:21

2 Answers2

1
<c:forEach var=".." items=".."><td>${..}</td></c:forEach>

But it really doesn't matter whether there are line breaks there or not.

For configuring trimming of whitespaces, check this: Strip whitespace from jsp output

Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
0
<table>
    <tr>
        <%
            for (int i = 0; i < 10; i++) {
        %>

        <td> 
            <% out.print("12-12-2011"); %>
        </td>

        <%
            }
        %>
    </tr>
</table>

try this way. hope it will works..

A N M Bazlur Rahman
  • 2,280
  • 6
  • 38
  • 51
  • I think you didn't understood the concrete question :) Plus, this is also not using JSTL as OP asked, it's following a discouraged way of writing JSPs as they did in prehistory. – BalusC Feb 04 '12 at 14:19