Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Mixing JSP Scriptlets and HTML

Share this post!
 Vote this!

Suppose you have to generate a table in HTML.  This is a common operation, and you may want to generate a table from a SQL table, or from the lines of a file.  But to keep our example simple, we will generate a table containing the numbers from 1 to N.  Not very useful, but it will show you the technique.
Here is the JSP fragment to do it:
<TABLE BORDER=2>
<%
    for ( int i = 0; i < n; i++ ) {
        %>
        <TR>
        <TD>Number</TD>
        <TD><%= i+1 %></TD>
        </TR>
        <%
    }
%>
</TABLE>  more...

0 comments:

Post a Comment