How to write a for loop in a JSP page?

JSPJava 8Object Oriented ProgrammingProgramming

Following is the for loop example −

<%! int fontSize; %>
<html>
   <head>
      <title>FOR LOOP Example</title>
   </head>
   <body>
      <%for ( fontSize = 1; fontSize <= 3; fontSize++){ %>
         <font color = "green" size = "<%= fontSize %>">
            JSP Tutorial
         </font><br />
      <%}%>
   </body>
</html>

The above code will generate the following result −

JSP Tutorial
JSP Tutorial
JSP Tutorial
raja
Published on 20-Mar-2019 11:18:17
Advertisements