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
Updated on: 2019-07-30T22:30:25+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements