Why don't you get count at the beginning, store it in a variable and then simple refer to it instead of running query every time you refresh view.

Hey Thanks for the participation in the post but as per the previous post cn u give the code on how to be able to use if statements to be able to prevent the array index out of bound exception! that happens cause the next record! IN MY PREVIOUS POST i have put the code to try out how to prevent the array index out of bound exception! may be u cud use the code to be able to help me out!

ALL HELP VERY MUCH APPRECIATED!

WANT TO THANK U ALL! U HAVE BEEN OF GREAT ASSISTANCE.

Hey Friends :-) I want to mark this thread solved once im done with this section!

Im close to getting the logic but since i have implemented the following CODE and when i click on the next record it gives me indexoutOfboundexception:

This is the logic implemented:

<%
String Count = request.getParameter("Counter");
int Counter = 0;
if(request.getParameter("Counter") != null) {
  Counter = Integer.parseInt(request.getParameter("Counter"));
}
BorrowerRecordViews Borrower = (BorrowerRecordViews)GetBorrowersRecord.get(Counter);            
%>
<% <%if (Counter>GetBorrowerRecord.size()) {%> 
<a href="ViewStudent.jsp?Counter=<%=Counter+1%>">VIEW NEXT RECORD</a>
 
<%}%>

<% <%if (Counter<GetBorrowerRecord.size()) {%> 
<a href="ViewStudent.jsp?Counter=<%=Counter-1%>">VIEW PREVIOUS RECORD</a>
 
<%}%>

hey friends! any luck with a solution! i want to mark it as solved! what cud be the problem with the code that i have displayed in my previous posts!

Hello everyone! Help please! I want to solve the indexoutofboundexception problem!

Hey everyone! i tried something new with the code! used the lastIndexof but the problem still comes... IndexOutOfBoundException:

<%
String Count = request.getParameter("Counter");
int Counter = 0;
if(request.getParameter("Counter") != null) {
  Counter = Integer.parseInt(request.getParameter("Counter"));
}
BorrowerRecordViews Borrower = (BorrowerRecordViews)GetBorrowersRecord.get(Counter);            
%>
<% <%if (Counter>GetBorrowerRecord.lastIndexOf)) {%> 
<a href="ViewStudent.jsp?Counter=<%=Counter+1%>">VIEW NEXT RECORD</a>
 
<%}%>
 
<% <%if (Counter<GetBorrowerRecord.lastIndexOf()) {%> 
<a href="ViewStudent.jsp?Counter=<%=Counter-1%>">VIEW PREVIOUS RECORD</a>
 
<%}%>

i USED A different method but the proble still comes any idea why! previously i used size but it still doesnt work!

All help highly appreciated

Don't use random methods. This isn't the lottery. Use logic.
Since you are writing jsps, you know how to loop an array:

for (int i=0;i<array.length;i++) {

Why you set i to be 0 and i<length ? You pass the counter at the request and you use it as argument at the get method.
The list has elements from 0 till size-1, so the counter must be within that range. So display the next, previous links only when the value at the Counter parameter of the links is within that range

commented: One for sticking with this guy, and hard time spoon-feeding :) +16

Hey Friend! im done! it works very well! just had to use the

response.sendRedirect

code.....

Here is the code im marking this code thread as solved:

<%
            //String Count = request.getParameter("Counter");
            int Counter = 0;
            if(request.getParameter("Counter") != null) {
            Counter = Integer.parseInt(request.getParameter("Counter"));
            }
            if (Counter==GetBorrowersRecord.size() || Counter==-1)
                {
                    response.sendRedirect("ViewStudent.jsp");
                }
            else
                {
            BorrowerRecordViews Borrower = (BorrowerRecordViews)GetBorrowersRecord.get(Counter);            
                
    %>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.