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



Home Answers Viewqa Development-process large nuber of records display to jsp

Have Programming Question? Ask it here!
 
 
 


Binoy
large nuber of records display to jsp
2 Answer(s)      5 years and 3 months ago
Posted in : Development process



Advertisement
View Answers

May 13, 2009 at 3:15 PM


Hi Friend,

We are providing you a code that will display the records to jsp page using pagination.Here we have specified 10 records per page.Try the following code:

pagination.jsp
---------------
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%!
public int nullIntconvert(String str)
{
int num=0;
if(str==null)
{
str="0";
}
else if((str.trim()).equals("null"))
{
str="0";
}
else if(str.equals(""))
{
str="0";
}
try{
num=Integer.parseInt(str);
}
catch(Exception e)
{
}
return num;
}
%>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://192.168.10.112:3306/student","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) {
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*showRows);
}
String query1="SELECT SQL_CALC_FOUND_ROWS * FROM mca limit "+iPageNo+","+showRows+"";
ps1=conn.prepareStatement(query1);
rs1=ps1.executeQuery();

String query2="SELECT FOUND_ROWS() as cnt";
ps2=conn.prepareStatement(query2);
rs2=ps2.executeQuery();
if(rs2.next()) {
totalRows=rs2.getInt("cnt");
}
%>


May 13, 2009 at 3:16 PM


continue...................

<html>
<h3>Pagination of JSP page</h3>
<body>
<form>
<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" >
<tr>
<td>Id</td>
<td>Name</td>
<td>Subject</td>
</tr>
<%
while(rs1.next()) {
%>
<tr>
<td><%=rs1.getInt("id")%></td>
<td><%=rs1.getString("name")%></td>
<td><%=rs1.getString("subject")%></td>
</tr>
<%
}
%>
<%
try{
if(totalRows<(iPageNo+showRows)) {
endResult=totalRows;
}
else{
endResult=(iPageNo+showRows);
}
startResult=(iPageNo+1);
totalPages=((int)(Math.ceil((double)totalRows/showRows)));
}
catch(Exception e){
e.printStackTrace();
}
%>
<tr>
<td colspan="3">
<div>
<%
int i=0;
int cPage=0;
if(totalRows!=0) {
cPage=((int)(Math.ceil((double)endResult/(totalRecords*showRows))));

int prePageNo=(cPage*totalRecords)-((totalRecords-1)+totalRecords);
if((cPage*totalRecords)-(totalRecords)>0){
%>
<a href="pagination.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
<%
}
for(i=((cPage*totalRecords)-(totalRecords-1));i<=(cPage*totalRecords);i++){
if(i==((iPageNo/showRows)+1)){%>
<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>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
<%
try{
if(ps1!=null){
ps1.close();
}
if(rs1!=null){
rs1.close();
}

if(ps2!=null){
ps2.close();
}
if(rs2!=null){
rs2.close();
}

if(conn!=null){
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>

Thanks


Related Tutorials/Questions & Answers:
large nuber of records display to jsp - Development process
large nuber of records display to jsp  I have 10000 records... to a jsp page using pagination. I want to display 1oo records per page, remaining... that will display the records to jsp page using pagination.Here we have
Display Records in Tree Format - JSP-Servlet
Display Records in Tree Format   hi i want to displays data in the tree format with root nodes, child nodes and leaf nodes in a jsp file... we have to pass values of root node subnodes and the leaf node to next jsp
Advertisements
display records with images problem - JSP-Servlet
display records with images problem  hello, i am developing HR application whereby i want to display employee records and their pictures on web... with a unique id. Also i wrote i jsp that link to servlet in order to display
retrieving newly added records from mssql database and display in a jsp
retrieving newly added records from mssql database and display in a jsp ... from mssql database table and display those records in a jsp.And i have to delete these 10 records from the jsp and retrieve the next recently added 10 records
I want to display 10,000 records in a jsp page.Can I display page by page?
I want to display 10,000 records in a jsp page.Can I display page by page?  When I submit a form it says "ERROR: Query request too large. Total rows... print page by page or have say 900 records per page in a jsp? Should I have
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
display 10 records per page in jsp - JSP-Servlet
display 10 records per page in jsp  hello, can i get a code that displays 10 records per page from a table student and when i click on the next button it displays the next 10 pages and so on. Im using jsp and mysql database
display 1000 of records - Struts
display 1000 of records  how to display 1000 of records using next... that we can display any number of records. Implement a sample   We have pagination concept in Java. Using that we can display any number of records
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
Upload and Download Large files in jsp
Upload and Download Large files in jsp  I am not able to download large files (>200mb) from any server. I need a code to download and upload large files (atleast 4 gb) to a server using jsp page
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List of records from database in a jsp using ajax, onclick it should display the results
please give me solution how to display next page after 20 records ? - JSP-Servlet
please give me solution how to display next page after 20 records ?  Java Servlet Paging control example  here i have attached one example code. function validate() { for(j=0;j<30;j
arraylist not able to store large amount of data( over 1 lakh records) - Java Interview Questions
arraylist not able to store large amount of data( over 1 lakh records)  A result set containing over 1 lakhs of records is used to set data to an object and in turn that object is added to an arraylist one by one iterating over
Data displaying with limited records in jsp
Data displaying with limited records in jsp  How to display table with limited 10 records , after clicking next button another 10 records from database upto last record please help me
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values
how can manages records in jsp
how can manages records in jsp  how can sho only five record at a time and next 5 on click next button and so on in jsp
How to display mysql database records as per clock timing?
How to display mysql database records as per clock timing?  I want to display database records as per clock timing
Retrieving newly inserted records and displaying in jsp forever
Retrieving newly inserted records and displaying in jsp forever  Sir... a table and display in jsp(Each row contains a field called as "session... records are inserted, i have to retrieve the newly inserted records and display
How to check no records - JSP-Servlet
project, in that how i have 2 check no records. I saw an answer... to check and display your cart is empty.... PLs help me......... Reply... not empty //display something else //false resultset empty //display something
printing records from jsp - JSP-Servlet
printing records from jsp  Hi Plz tell me how to printing out pages..., For paging in Jsp visit to : http://www.roseindia.net/jsp/paging.shtml http://www.roseindia.net/jsp/bank.shtml Thanks
displaying both image and records problem in jsp and servlet - JSP-Servlet
displaying both image and records problem in jsp and servlet  hello... the application to display more than one employee records and their pictures. e.g. say i'm having records like: firstname, lastname, empid, department, salary, job_title
displaying images and records problem - JSP-Servlet
it, all what i want is to display staff records and their pictures on the web pages...displaying images and records problem  hi, Thanks for your reply... display any record and image. I posted my question and since then no replay
displaying employee records and their images problem - JSP-Servlet
displaying employee records and their images problem  hi, Thanks for your reply to my question. The code you sent to me yesterday was not working. it doesn't display any record and image. Please, help me out urgent
Display Java in JSP
Display Java in JSP  please i need urgent help. How can i display Java Applet created in netbeans in JSP?. the Application involves MYSQL Database connection. Thanks
image display - JSP-Servlet
image display  how to display image that store in mysql database... column have BLOB datatype....  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
display image using jsp
display image using jsp  display image using jsp and phonegap on emulator of eclipse   Here is a simple jsp code that displays an image on browser. <%@ page import="java.io.*" %> <%@page contentType="image/gif
dynamic display - JSP-Servlet
dynamic display  hi, i want to display dynamic values in drop drown box in a jsp page.these values are in the form of arraylist's object which... javax.servlet.http.*; public class DataServlet extends HttpServlet{ String page="/jsp
cannot display an arrayList in JSP
cannot display an arrayList in JSP  Hello, My bean is called Zone, i got all Zones from sql Server with Hibernate. in DAO.Class: print("List zones... a servlet to a jsp. In servlet.class print("List result = dao.getListZone
Jsp Image Display
Jsp Image Display  Hi,i need to display image in a Box like... to save it in a database....Kindly post JSP codes..Its Urgent, I m very thankful t...;<TITLE>Display file upload form to the user</TITLE></HEAD> <
Time display - JSP-Servlet
Time display   In a web application or ina website if we display the time getting as system time, whether it is server' system time or client' system time. Is there any difference between getting time using java Date
jsp image display
jsp image display  this is my saveImage.jsp file: <% ServletContext context = pageContext.getServletContext(); String initPath = context.getInitParameter("file-upload"); String filePath=initPath; String path
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
how to display the email message in jsp
how to display the email message in jsp  hi every one .. i am new from this industry please help me to display the email message in jsp page please send me sample code
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I need to retrieve the records from the database for every 7 seconds and display...; In between the <div></div> I have to display the records. I am displaying
image display in jsp - Java Beginners
image display in jsp  i uploaded the image and how can i print that image in next jsp page....  Hi friend, read for more information, http://www.roseindia.net/jsp/file_upload/employee_upload_profile_image.shtml
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date will disappeared or non-clickable and its show in red color. those date
display messages in short - JSP-Servlet
display messages in short  hi sir, i am getting a full text message and that is shown in the table after sending a email.But now i have... in javascripts or in jsp... Thanks and Regards Harini V
display of colors in a table - JSP-Servlet
display of colors in a table  Hi, If i have a table of 4 by 4 boxes, numbering from 1-16 in sequence, how do i make them display one column of one..., Try the following jsp code: table.jsp: Column1,Row1
Jsp not display desired result - JSP-Servlet
Jsp not display desired result  Hello all, I want to be able to display picture from Ms Sql 2000 using JSP. Below is the code I used but does not display anything. Please assist me. Thanks
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai, this is my jsp where i have enter multiple username and password and save it to database in single hit user.jsp <form action="UserServlet" method="post
To Display the 'Last Modified' message in JSP
To Display the 'Last Modified' message in JSP  I have to display... using JSP I have used this below coding but I'm not getting the solution can anyone...;In JSP I've called the function in the 'On Change' in the below code <tr>
large resultset values - SQL
large resultset values  i have one query which will bring more than one lakh records from database(total records are abt 3 crores). While getting... "com.microsoft.sqlserver.jdbc.SQLServerException: The system is out of memory. Use server side cursors for large result
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file containing a method which is returning an ArrayList. I want to display the records
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
How to display multiple images in jsp
How to display multiple images in jsp  <%@ page import="java.io....()); System.out.println("st-7 "+brr); // display the image response.setContentType("image... "); } } catch (Exception e) { out.println("Unable To Display image"); out.println
display messages in short - JSP-Servlet
display messages in short  dear sir, i am sending a mail and then dialaing all subject, matter and attached file in the table .But in table i have to ge a short message i.e starting few words then dots ,when a mouse
display messages in short - JSP-Servlet
display messages in short  dear sir, i am sending a mail and then displaying all subject, matter and attached file in the table .But in table i have to get a short message i.e starting few words then dots like that ,when a mouse
display messages in short - JSP-Servlet
display messages in short  dear sir, I am able to send a email and also i am able to getting a message from that email ,storing that in a data base and retrieving showing that in a table .But now i want to get
 

 

 

DMCA.com