Here the code in doPost method after getting the result... keep iit vector v
v = new Vector(msgList);
log.info("Vector in QueryServlet from MessageBean: " +v);
if(v != null && v.size()>0)
{
log.info("Vector in QueryServlet from MessageBean: " +v.size());
mr = (MsgReply)v.get(0);
System.out.println("MsgReply in QueryServlet : "+mr);
if(mr != null && mr.getMsgId()!=null)
{
log.info("Vector size in QueryServlet: " + v.size());
session.setAttribute("mhb/MessageReplyVec", v);
int noOfRecPerPage = 0;
//Integer.parseInt(bundle.getString("No_Of_Messages"));
try
{
String str_No_Of_Records = bundle.getString("No_Of_Messages");
if(str_No_Of_Records != null && str_No_Of_Records.trim().length() != 0)
{
noOfRecPerPage = Integer.parseInt(str_No_Of_Records);
}
System.out.println("No of Messages : --"+bundle.getString("No_Of_Messages")+"--");
}
catch(NumberFormatException nfe)
{
System.out.println("NumberFormatException : "+nfe);
}
catch(java.util.MissingResourceException mre)
{
System.out.println("MissingResourceException : "+mre);
}
if(noOfRecPerPage > 0)
{
int endIndex = 0;
if(noOfRecPerPage > v.size())
{
endIndex = v.size();
}
else
{
endIndex = noOfRecPerPage;
}
List l = v.subList(0,endIndex);
Vector vsub = new Vector(l);
log.info("Vector sub in QueryServlet: " + vsub);
log.info("Vector sub size in QueryServlet: " + vsub.size());
req.setAttribute("mhb/MessageReplyVecReq", vsub);
}
else
{
req.setAttribute("mhb/MessageReplyVecReq", v);
}
session.setAttribute("mhb/MessageReplyVecSize", new Integer(v.size()));
Here the code in doGet method
int noOfRecPerPage = Integer.parseInt(bundle.getString("No_Of_Messages"));
log.debug("NEXT BUTTON");
Vector v = (Vector)session.getAttribute("mhb/MessageReplyVec");
log.debug("V.Size : "+v.size());
log.debug("noOfRecPerPage : "+noOfRecPerPage);
int noOfRec = v.size();
int pageNo = 0;
if(req.getParameter("pageNo") != null){
pageNo = Integer.parseInt(req.getParameter("pageNo"));
}
int startIndex = 0;
int endIndex = 0;
if(pageNo > 1){
startIndex = pageNo*noOfRecPerPage-noOfRecPerPage;
}
endIndex = startIndex+noOfRecPerPage;
if(endIndex > noOfRec){
endIndex = noOfRec;
}
List l = v.subList(startIndex,endIndex);
Vector vsub = new Vector(l);
req.setAttribute("mhb/MessageReplyVecReq", vsub);
Dispatch();
Here the code in JSP page:-
int noOfRecPerPage = 0;
try {
String str_No_Of_Records = bundle
.getString("No_Of_Messages");
if (str_No_Of_Records != null
&& str_No_Of_Records.trim().length() != 0) {
noOfRecPerPage = Integer
.parseInt(str_No_Of_Records);
}
} catch (NumberFormatException nfe) {
System.out.println("NumberFormatException : " + nfe);
} catch (java.util.MissingResourceException mre) {
System.out.println("MissingResourceException : " + mre);
}
if (noOfRecPerPage == 0) {
noOfRecPerPage = vSize;
}
int noOfPages = 0;
String pageNo = request.getParameter("pageNo");
if (request.getParameter("pageNo") != null
&& !(request.getParameter("pageNo").equals(""))) {
pageNo = request.getParameter("pageNo");
} else {
pageNo = "1";
}
if (vSize % noOfRecPerPage == 0) {
noOfPages = vSize / noOfRecPerPage;
} else {
noOfPages = vSize / noOfRecPerPage + 1;
}