greetings venu
Thanx a lot for your help however in the below code of previous and next fuctionality.
i'm trying to add one more column in result rows and subsequently on the array list to match both the parameters
The code is working fine with five strings(r5,r6,r7,r8,r9) wheni try to add another String r6 below and subsequenly in the array list it gives me Internal server error.Logically i can add any number of strings in it to display the records
The code works with 5 strings but with the addition of string it gives an erroe
I wasted the whole day today and was fixed on this problem.
PLEASE HELP ME OUT.i UNDERSTAND ITS A BOTHERATION BUT NEED YOUR SOLICITATED ADVICE
ABY
public class ResultRows {
private String r5;
private String r6;
private String r7;
private String r8;
private String r9;
public ResultRows() {
}
public ResultRows(String r5, String r6, String r7, String r8, String r9) {
this.r5 = r5;
this.r6 = r6;
this.r7 = r7;
this.r8 = r8;
this.r9 = r9;
}
public String getR5() {
return r5;
}
public void setR5(String r5) {
this.r5 = r5;
}
public String getR6() {
return r6;
}
public void setR6(String r6) {
this.r6 = r6;
}
public String getR7() {
return r7;
}
public void setR7(String r7) {
this.r7 = r7;
}
public String getR8() {
return r8;
}
public void setR8(String r8) {
this.r8 = r8;
}
public String getR9() {
return r9;
}
public void setR9(String r9) {
this.r9 = r9;
}
}
<%@ page import="java.util.ArrayList,
java.util.Iterator,
java.util.List,
ResultRows,
java.sql.ResultSet,
java.sql.Statement,
java.sql.DriverManager,
java.sql.Connection"%>
<%
ArrayList arrayList = null;
boolean check = true;
// session.removeAttribute("arrayList");
/* if you have the arrayList in the session Object avoid the DB Call
and get the ArrayList from the session Object
*/
String r1,r2,r3,r4,r5,r6,r7,r8,r9,r10=" ",r11=" ",r12,r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,r25;
if(null == session.getAttribute("arrayList"))
{
/** need to get the ArrayList from the DB */
arrayList = new ArrayList();
// START OF COMMIT LINE
for(int i=0; i<10; i++)
{
arrayList.add(new ResultRows("r5"+i,"r6"+i,"r7"+i,"r8"+i,"r9"+i));
}
// END OF COMMIT LINE
//START OF UNCOMMIT LINE
/* Connection con = null;
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/archiving");
Statement stmt = con.createStatement();
String sql;
int currentRs =10;
sql = "Select * from relationship_archive_extract where relationship_archive_extract.id='2380' LIMIT "+ currentRs +",10";
ResultSet rs = stmt.executeQuery(sql);
//rs.absolute(10);
while (rs.next())
{
r5 = rs.getString("account_no");
r6 = rs.getString("account_type");
r7 = rs.getString("prod_desig");
r8 = rs.getString("relationship_type");
r9 = rs.getString("primary_owning_cust");
// //
arrayList.add(new ResultRows(r5,r6,r7,r8,r9));
}
*/
// END OF UNCOMMIT LINE
session.setAttribute("arrayList", arrayList);
}else{
arrayList = (ArrayList)session.getAttribute("arrayList");
}
int arrayListSize = arrayList.size();
// Number of Records that need to displayed per page
// make the increment value 5 and check it will display only 5 records per page
int increment = 2;
int fromIndex = 0;
int toIndex = increment;
String uri = request.getRequestURI();
String previous= "Previous";
String next = "Next";
List displayList = null;
if( null != request.getParameter("next"))
{
fromIndex = Integer.parseInt(request.getParameter("next"));
toIndex = increment + fromIndex;
if( toIndex+1 > arrayListSize)
{
toIndex = arrayListSize;
check = false;
}
if( fromIndex > arrayListSize)
fromIndex = 0;
}
if( null != request.getParameter("prev"))
{
toIndex = Integer.parseInt(request.getParameter("prev"));
fromIndex = toIndex - increment;
}
if(arrayListSize > 0)
{
if(increment > arrayListSize){
toIndex = arrayListSize;
displayList = arrayList.subList(fromIndex, toIndex);
toIndex = 0;
}else{
displayList = arrayList.subList(fromIndex, toIndex);
}
}
if(fromIndex != 0 )
previous = "<a href="+ uri +"?prev="+ fromIndex +"> Previous </a>";
if(toIndex != 0 && check)
next = "<a href="+ uri +"?next="+ toIndex +"> Next </a>";
/* out.println(arrayList);
out.println("<br>");
out.println(displayList);
out.println("<br>");
out.println(next);
out.println("<br>");
out.println(previous);*/
%>
<!- TABLE FOR DETAILS STARTS HERE -->
<div id="Layer9" style="position:absolute; width:982px; height:372px; z-index:42; left: 16px; top: 169px; background-color: #DFE9F9; layer-background-color: #DFE9F9; border: 1px none #000000;">
<!- TABLE FOR DETAILS ENDS HERE -->
<!- TABLE FOR 2nd DETAILS STARTS HERE -->
<!- TABLE FOR 2nd DETAILS ENDS HERE -->
<div id="Layer18" style="position:absolute; width:683px; height:299px; z-index:46; left: 4px; top: 46px;">
<table width="100%" height="24" border="0">
<caption> <%=next%> <%=previous%></caption>
<tr>
</strong>
</td>
<td width="6%"><div align="center"> <strong>
Account No
</strong></div>
</td>
<td width="26%"><div align="center"><strong>
Account Type
</strong></div>
</td>
<td width="21%"><div align="center"><strong>
Prod Design
</strong></div>
</td>
<td width="28%"><div align="center"><strong>
Relationship
</strong></div>
</td>
</tr>
<%
Iterator iterator = displayList.iterator();
while(iterator.hasNext())
{
ResultRows resultRows = (ResultRows)iterator.next();
%>
<tr>
</strong>
</td>
<td width="6%"><div align="center"> <strong>
<%=resultRows.getR6()%>
</strong></div>
</td>
<td width="26%"><div align="center"><strong>
<%=resultRows.getR7()%>
</strong></div>
</td>
<td width="21%"><div align="center"><strong>
<%=resultRows.getR8()%>
</strong></div>
</td>
<td width="28%"><div align="center"><strong>
<%=resultRows.getR9()%>
</strong></div>
</td>
</tr>
<%}%>
</table>
<strong>
</strong> </div>
</div>