Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Have Programming Question? Ask it here!

Bhubanmohan Muduli
3 Answer(s)      2 years ago
Posted in : Java Server Faces Questions

i want to make online exam server by jsf 1.2 please tell me how to paginate questions without refreshing page

View Answers

July 30, 2012 at 11:14 AM

Here is a jsp code of pagination. In the given code,we have taken the database table student(rollNo,name,marks,grade).

<%@ page language="java" %>
<%@ page import="java.sql.*" %>
public int nullIntconvert(String str){
int num=0;
if(str==null) {
else if((str.trim()).equals("null")) {
else if(str.equals("")) {
catch(Exception e) { }
return num;
Connection conn = null;
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
ResultSet rs1 = null;
ResultSet rs2 = null;
PreparedStatement ps1=null;
PreparedStatement ps2=null;

int showRows=10;
int totalRecords=10;
int totalRows=nullIntconvert(request.getParameter("totalRows"));
int totalPages=nullIntconvert(request.getParameter("totalPages"));
int iPageNo=nullIntconvert(request.getParameter("iPageNo"));
int cPageNo=nullIntconvert(request.getParameter("cPageNo"));

int startResult=0;
int endResult=0;
if(iPageNo==0) {
String query1="SELECT SQL_CALC_FOUND_ROWS * FROM student limit "+iPageNo+","+showRows+"";

String query2="SELECT FOUND_ROWS() as cnt";
if( {
<h3>Pagination of JSP page</h3>
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="showRows" value="<%=showRows%>">
<table width="100%" cellpadding="0" cellspacing="0" border="1" >
<td>Roll No</td>
while( {

July 30, 2012 at 11:16 AM


if(totalRows<(iPageNo+showRows)) {
catch(Exception e){
<td colspan="3">
int i=0;
int cPage=0;
if(totalRows!=0) {

int prePageNo=(cPage*totalRecords)-((totalRecords-1)+totalRecords);
<a href="pagination.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
<a href="pagination.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
else if(i<=totalPages){
<a href="pagination.jsp?iPageNo=<%=i%>"><%=i%></a>
if(totalPages>totalRecords && i<totalPages){
<a href="pagination.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a>
<b>Rows <%=startResult%> - <%=endResult%> Total Rows <%=totalRows%> </b>


catch(Exception e)

Save the code with the name pagination.jsp.

Hope that it will be helpful for you.

July 30, 2012 at 3:53 PM

here problem is that : suppose i have 10 questions and i make 1 page per question . if user click on 1st question and checked the answer after moving to 2nd question this page is refreshing by which last data is lost

i dont want to forward data to next page by refreshing , i want to stop refresh in page

Related Tutorials/Questions & Answers:
Pagination  How to apply pagination in JSP. Please help
Pagination  How to implement pagination in struts using hibernate
pagination  How to set pagination using java script to display data
Pagination  How to create pagination in jsp with EJB using MS SQL
Pagination  I want to write one where condition in sql query in pagination concept
Pagination  Is their plug n play approach for creating pagination? 1) Server side as well as client side
pagination   Simple way for pagination in jsp using java script to display data without send database
Pagination  I want to know how to use pagination in jsp. I have a list object from that i want to display 3 questions per page can u help me
pagination  I need to give pagination with where condition (query="select * from qtn where qid='"+replyQuesionId+"'limit "+iPageNo+","+showRows+"" ) like this I want, without where condition it is working but with condition
pagination  I need to give pagination with where condition (query.......   Here is a simple jsp pagination code where we have used mysql database...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
=rs2.getInt("cnt"); } %> Pagination of JSP page Terr_Code Terr_Name
code of pagination. In the given code,we have taken the database table student...;Pagination of JSP page</h3> <body> <form> <input type="hidden
Pagination  pagination in jsp   Hi Friend, Try the following code: <%@ page language="java" %> <%@ page import="java.sql.*" %>...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
pagination  how can i start pagination in jsp?   Hi Friend, Try the following code: <%@ page language="java" %> <%@ page import...;Pagination of JSP page</h3> <body> <form> <input type="hidden
Pagination in java
Pagination in java  How to handle pagination when there are records like say in millions in java? Or do we handle this using SQL? I as asked... far good performance then Java pagination. Thanks
jsp pagination
jsp pagination  I want to implement pagination on jsp page Each jsp page having some radio buttons, on click of next previous page selected radio buttons are reset. I want to maintain state of selected radio buttons on previous
pagination in jsf
pagination in jsf  Hi , i am implemeting an online exam system , i have placed my questions as an arraylist in my jsp file within tag , but now i want to paginate these questions based on respective questions by clicking
JSP Pagination
to be shown, I want to implement Pagination.. Can someone show me a sample code which I could possibly use??   JSP Pagination pagination.jsp: <%@ page..."); } %> <html><h3>Pagination of JSP page</h3> <body><
Hibernate Pagination
In this tutorial we will discuss concept of pagination in hibernate
jsf pagination
of pagination. In the given code,we have taken the database table student(rollNo,name,marks...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP
Pagination in jsp - JSP-Servlet
Pagination in jsp  I need an example of pagination in JSP using display tag
Two Pagination in one page
Two Pagination in one page  hai friends any one help me. how do u make two pagination script in same page i'm used some ajax coding one pagination script is working but another pagination is not working please help me urgent
Pagination example with html code
Pagination example with html code  Hi, could u please provide pagination code with clear cut explanation. Thanks in advance
pagination in hibernate with jsp
pagination in hibernate with jsp  Hi, plz give me example on pagination .   Hi Friend, Visit Here Thanks
pagination - JSP-Servlet
pagination  Hi, could u tell me how i will handle pagination... friend, Simple pagination in jsp Simple pagination in JSP... Simple pagination in jsp Displaying Records
pagination in jsp - JDBC
pagination in jsp  Hi, I have millions of records in my oracle d... in advance...   Hi friend, This is simple code of pagination. Simple pagination in jsp
Pagination without using database in php
Pagination without using database in php  How can I show multiple images in multiple rows with pagination in php
pagination+dynamic pagesize+hibernate - Struts
pagination+dynamic pagesize+hibernate  pagination using hibernate with dynamic page size plzz heilp me
Pagination in PHP code - PHP
Pagination in PHP code  3.Pagination in PHP codeIs it possible to get the paging in PHP without database call? How will I show the image instead of numbering? any code that can help
pagination in php - Ajax
pagination in php  i want to fetch my data base in view page...i hav done pagination... i don't want the 1 2 3 4 . . . last i want the order in... 1 2 3 4 5 6 7
Pagination Using Displaytag Lib
Pagination Using Displaytag Lib  I am using Struts 1.2 for my web based project. While using display tag lib in jsp for pagination, is there any substitute of using As I dont want to be dependent on any site(s). Please
Pagination - JSP-Servlet
Pagination  I want to display only 10 records but my arraylist contains for example about 100 records... My jsp page should contain 10 records along with the pagination below.... like prev 1 2 3 4 5 next I am using
Jsp pagination - JSP-Servlet
tell me the solution  Hi friend, For Jsp pagination application
Pagination Example
; In this section, you will learn how to create pagination in struts 2. For creating pagination in your application follows the certain steps: Download...;a href="roseindia/pagination.action">Pagination Example</a></li>
Paging or pagination - Development process
Paging or pagination to do paging or pagination in jsp using servlets? I have a 20 records ,i have to show them in 2 pages like pages 1 2...("Starting index is "+startIndex); %> Pagination The Following
pagination in hibernate with jsp
pagination in hibernate with jsp  Hi, plz give me example on pagination .   Hi Friend, We have used MySql database with JSP...>Pagination of JSP page</h3> <body> <form> <input type
pagination problem - JSP-Servlet
pagination problem  Thanks sir for posting the answer.But i have 2 problems 1.i have created one employee class in that i use getter and setter...(),my problem is that where i have to put & how to do pagination? my code
pagination problem - JSP-Servlet
pagination problem   Thanks sir for posting the answer.But i have 2 problems 1.i have created one employee class in that i use getter and setter...(),my problem is that where i have to put & how to do pagination? my code
Checkbox pagination problem
Checkbox pagination problem  HI ., Following is my code test.jsp <%@page import="java.sql.*"%> <%@taglib prefix="c" uri="/WEB-INF/c-rt.tld" %> <%@page import="java.util.HashMap"%> <%@page import
Pagination with condition using servlet or jsp
Pagination with condition using servlet or jsp  Hi, Thanks in advance. I have a requirement like this, In front-end page I have one text...")", Then I want perform the pagination based on the string value(I mean pagination
dynamic pagination in jsp - JSP-Servlet
dynamic pagination in jsp  i am unable to display the data in multiple pages. I am gettting data from the database from the javaBeans to jsp by vectors... but i am unable to displaying them in jsp 15 records per page
store pagination form fields - Struts
store pagination form fields   hi,iam working online exams project . my intention is to save data that has been asnwered by client/student into db table. here iam using pagination for questions to be displayed to client
Hibernate Criteria Pagination
Hibernate Criteria Pagination You can easily make a pagination based application in Hibernate Criteria. You need to do the things that set first result...(end); An example of hibernate criteria pagination is given below
Pagination in jsp using oracle and not sql
Pagination in jsp using oracle and not sql  I need the code for pagination in jsp using oracle. I already tried it with rownum between instead... Pagination using Mysql database <%@ page language="java" %> <%@ page
pagination in JSP - JSP-Interview Questions
pagination in JSP  Hi! Everybody.. I am new to JSP. I am doing project using JSP. Everything is OK. When i am displaying the data from ResultSet. I am getting bulk data in the same page. Ex:ExecuteQuery("select * from
In pagination how to hilight the links - JSP-Servlet
In pagination how to hilight the links  Dear Sir, Thanks for posting the answer,its working fine.Now i want google or others like pagination ,in that if i click on a number only that number color will be changed like
write a java program for pagination which will be configured by end user
write a java program for pagination which will be configured by end user  write a java program for pagination which will be configured by end user... Pagination