How to write a while loop in a JSP page?


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

942 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements