How to write a while loop in a JSP page?

JSPJava 8Object Oriented ProgrammingProgramming

Following is the while loop example −

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

The above code will generate the following result −

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