auto resize

Ads
 

auto resize

Dear Sir, I have a table with 60 coloumns and 90 rows.If i give the print option it s not comin in one page.Can you please tell me the javascript code for auto resizing it into one window or fit to the window while taking the print.

Regards Debasis

View Answers

December 7, 2010 at 4:43 PM

Hi Friend,

You can do paging using jsp.

Here is the 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://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) {
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*showRows);
}
String query1="SELECT SQL_CALC_FOUND_ROWS * FROM student 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");
}
%>
<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>Roll No</td>
<td>Name</td>
<td>Marks</td>
<td>Grade</td>
</tr>
<%
while(rs1.next()) {
%>
<tr>
<td><%=rs1.getInt("rollNo")%></td>
<td><%=rs1.getString("name")%></td>
<td><%=rs1.getInt("marks")%></td>
<td><%=rs1.getString("grade")%></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>

December 7, 2010 at 4:44 PM

continue....

<%
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();
}
%>

In the above code,we have created the database table student(rollNo,name,marks,grade).

Thanks

Ads









Related Tutorials/Questions & Answers:
Objective C resize UIImage
Objective C resize UIImage  i just want to resize the image on the touch detection. That means if a user double clicks on the UIImage it must resize the image
ModuleNotFoundError: No module named 'resize'
ModuleNotFoundError: No module named 'resize'  Hi, My Python... 'resize' How to remove the ModuleNotFoundError: No module named 'resize'... to install padas library. You can install resize python with following command
Advertisements
Resize image stored in database
Resize image stored in database  hi, Can any one please send code for how to resize image stored in database in blob datatype in jsp, i want to resize it to 140(w)*160(h) please help me
auto
auto  write a java code design an auto with as many feature as possible
Resize Header in CSS
Resize Header in CSS  Hi all, Please let me know if we can resize the Header tags in HTML for example H1,H2 and so on... Actually, it looks very...;We can resize header tags in CSS .. and further call that class into you HTML
ModuleNotFoundError: No module named 'Flask-Resize'
ModuleNotFoundError: No module named 'Flask-Resize'  Hi, My Python... 'Flask-Resize' How to remove the ModuleNotFoundError: No module named 'Flask-Resize' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Flask-Resize'
ModuleNotFoundError: No module named 'Flask-Resize'  Hi, My Python... 'Flask-Resize' How to remove the ModuleNotFoundError: No module named 'Flask-Resize' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'image_resize'
ModuleNotFoundError: No module named 'image_resize'  Hi, My Python... 'image_resize' How to remove the ModuleNotFoundError: No module named 'image_resize' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'resize-and-crop'
ModuleNotFoundError: No module named 'resize-and-crop'  Hi, My... named 'resize-and-crop' How to remove the ModuleNotFoundError: No module named 'resize-and-crop' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Resize-CMD'
ModuleNotFoundError: No module named 'Resize-CMD'  Hi, My Python... 'Resize-CMD' How to remove the ModuleNotFoundError: No module named 'Resize-CMD' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'js.jquery_ba_resize'
ModuleNotFoundError: No module named 'js.jquery_ba_resize'  Hi, My... named 'js.jquery_ba_resize' How to remove the ModuleNotFoundError: No module named 'js.jquery_ba_resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-resize-image'
ModuleNotFoundError: No module named 'python-resize-image'  Hi, My... named 'python-resize-image' How to remove the ModuleNotFoundError: No module named 'python-resize-image' error? Thanks   Hi
ModuleNotFoundError: No module named 'lektor-netlify-lfs-resize-url'
ModuleNotFoundError: No module named 'lektor-netlify-lfs-resize-url'  ...: No module named 'lektor-netlify-lfs-resize-url' How to remove the ModuleNotFoundError: No module named 'lektor-netlify-lfs-resize-url' error
ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column'
ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column' ...: ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize
ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column'
ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column' ...: ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize-column' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-web-tree-resize
ModuleNotFoundError: No module named 'odoo12-addon-web-tree-resize-column'
ModuleNotFoundError: No module named 'odoo12-addon-web-tree-resize-column' ...: ModuleNotFoundError: No module named 'odoo12-addon-web-tree-resize-column' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-web-tree-resize
ModuleNotFoundError: No module named 'odoo8-addon-website-mail-snippet-vertical-resize-base'
-resize-base'  Hi, My Python program is throwing following error...-vertical-resize-base' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-website-mail-snippet-vertical-resize-base' error? Thanks
Resize outer div when inner div's height increases
Resize outer div when inner div's height increases   How can I increase the outer div height automatically when inner div's height increases in javascript
auto update codings
auto update codings  auto update coding in xml
What is Auto Wiring?
What is Auto Wiring?  Hi, What is Auto Wiring? Thanks
how to generate auto code ?
how to generate auto code ?  i wanna genrate auto code for id in core java. pls tell me code of auto genrate
ModuleNotFoundError: No module named 'auto'
ModuleNotFoundError: No module named 'auto'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'auto' How to remove the ModuleNotFoundError: No module named 'auto' error
auto sql script - SQL
auto sql script  Is there a way of generating inserts scripts using the table structure for oracle database
Auto Generated Employee ID
Auto Generated Employee ID  Hello Everyone I want to generate an ID like (SCS-0001) and then it should be auto incremented each time a new employee add page is opens. I am using My Sql database
Date auto format
Date auto format  Hi, I have jsp page and Date field with input type. Requirement is, if we enter date as MMDDYY or MMDDYYYY and clicking the tab the date(MMDDYY or MMDDYYYY) have to auto format to MM/DD/YYYY. could you please
Stumped with NOT NULL AUTO_INCREMENT
Stumped with NOT NULL AUTO_INCREMENT  I've almost made it through my... to create a new table with the ID column being NOT NULL AUTO_INCREMENT. The table will create if I do not have NOT NULL AUTO_INCREMENT, but it WILL NOT create
Auto field update
Auto field update  In my application I have a field called status which is having the 4 values like new,submitted,approved, rejected. How to set those filed in Database(MySQL), and how to auto update that field status in other
Version of com.alta189>auto-spark dependency
List of Version of com.alta189>auto-spark dependency

Ads