So i have created a code that display database record into a html textbox and I am able to move to the next record and move back a record using a javascript function that I assign to a button. but i having trouble creating a function that will allow me to move to the last record and a button to move back to the first record.
<%@ page import="java.sql.*" %>
    <% Class.forName("com.mysql.jdbc.Driver");%>
    <HTML>
        <HEAD>
        </HEAD>
        <BODY>
            <FORM NAME="form1" METHOD="POST">
                <%
                    int current = 1;
                    if (request.getParameter("hidden") != null) {
                        current = Integer.parseInt(request.getParameter("hidden"));
                    }
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost", "root", "symphonia23");
                    Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
                    statement.executeQuery("use books");
                    ResultSet resultset = statement.executeQuery("select * from books");
                    if (current < 1) {
                        current = 1;
                    }
                    resultset.last();
                    int rows = resultset.getRow();
                    if (current <= rows) {
                        resultset.absolute(current);
                    }
                %>
                Code: <input type="text" id="code"  value="<%=resultset.getString("BookCode")%>"><br>
                Book Title: <input type="text" name="Code" value="<%=resultset.getString("BookTitle")%>"><br>
                Book Price: <input type="text" name="Code" value="<%=resultset.getString("BookPrice")%>"><br>
                <BR>
                <INPUT TYPE="HIDDEN" NAME="hidden" VALUE="<%= current%>">
                <INPUT TYPE="BUTTON" VALUE="Next" ONCLICK="moveNext()">
                <INPUT TYPE="BUTTON" VALUE="Prev" ONCLICK="movePrevious()">
                 <INPUT TYPE="BUTTON" VALUE="First" ONCLICK="movefirst()">
            </FORM>
                <SCRIPT LANGUAGE="JavaScript">
                    <!--
                function moveNext()
                    {
                        var counter = 0
                        counter = parseInt(document.form1.hidden.value) + 1
                        document.form1.hidden.value = counter
                        form1.submit()
                    }
                    function movePrevious()
                    {
                        var counter = 0
                        counter = parseInt(document.form1.hidden.value) - 1
                        document.form1.hidden.value = counter
                        form1.submit()
                    }
                     function movefirst()
                      {
                        var counter = 0
                        counter = parseInt(document.form1.hidden.value) 
                        document.form1.hidden.value = counter
                        form1.submit()
                    }
                    // --> 
            </SCRIPT>
        </BODY>
    </HTML>
 
     
    