Using a function properly inside a JSP file
===

I want to print out 3 buttons using a function inside the jsp file. what is the right way to do so, because my way seems to be wrong.

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Test Page</title>
            
            <%!
            int j = 3;
            %>
            
            <%!
            public void manyLabels() {
                for (int i = 0; i < j; i++) {
                    %>
                    <input type="button" value="button<%=i%>"/>
                    <%!                
                }
            }
                    
            %>        
        </head
        >
        <body>
            
            <% manyLabels(); %>
                    
        </body>
    </html>