auto resize

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









Related Tutorials/Questions & Answers:
auto resize
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
auto
auto  write a java code design an auto with as many feature as possible
Advertisements
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
resize a panel slowly - IDE Questions
resize a panel slowly  How to code to resize a panel slowly with netbeans
resize the tiff file - WebSevices
resize the tiff file  please guide me how i resize the tiff file and i want to upload it?   You can resize the tiff image as well as other type image. I am sending code, i hope it will help to you... Thanks
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
Image Resize in Flex
Image Resize in Flex  Hi....... I am going to add images into a tag. How will it resize itself? Please tell me about that.... Thanks  Ans: The image resize is the part of laying out of your application. you
Resize browser in flex
Resize browser in flex  Hi........ Please tell me about How can I Resize the Internet Explorer browser window from flex ? please give me the appropriate answer Thanks  Ans: UsegetURL() to communicate
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 '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 '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
Spark Resize effect in Flex4
Spark Resize effect in Flex4: The Resize effect changes the height, width... and shrink the size of component using Resize effect.  The tag of Resize effect is <s:Resize>. In this example you can see how we can use a Resize
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 '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
MX Resize Effect in Flex4
MX Resize Effect in Flex4: The Resize effect changes the height, width or both... the size of component using Resize effect. The tag of Resize effect is <mx:Resize>. In this example you can see how we can use a Resize effect
resize the tiff file in php - WebSevices
resize the tiff file in php  please guide me how i resize the tiff file and i want to upload it? using php  Hi I am sending the code of file upload in php. please check it, i hope it will help you... FileUpload.php
resize dynamic image in jsp - JSP-Servlet
resize dynamic image in jsp  Sir, I am saving the images in mysql database with Blob. An I am retrieving the images with this code:- I am getting my image with this code but all I need that I want to resize
i want to resize the tiff file also - WebSevices
i want to resize the tiff file also  if($objFiles['photo']['name...']); $FileName= time().$objFiles['photo']['name']; $this->resize_image...'],180,135); } function resize_image($src,$dest,$type,$new_width,$new
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 image with the change in size of jpanel.. - Java Beginners
resize image with the change in size of jpanel..  hi.. i am try to insert image in jpanel in jform to give attractive look to application,but the of image do not changes if the size of jframe or jpanel changes. if there is any
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
i want to resize tiff formated file in php - WebSevices
i want to resize tiff formated file in php  i know how to resize the jpeg,gif,png files but i need the code only for "tiff" files ? plz send guide lines for how to resize the tiff files?  Hi raja I could help better
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
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
org.wicketstuff - wicketstuff-jwicket-ui-resize version 6.5.0 Maven dependency. How to use wicketstuff-jwicket-ui-resize version 6.5.0 in pom.xml?
org.wicketstuff  - Version 6.5.0 of wicketstuff-jwicket-ui-resize Maven... of wicketstuff-jwicket-ui-resize in pom.xml? How to use wicketstuff-jwicket-ui-resize version...-resize in project by the help of adding the dependency in the pom.xml file
auto sql script - SQL
auto sql script  Is there a way of generating inserts scripts using the table structure for oracle database
Maven Repository/Dependency: org.wicketstuff | wicketstuff-jwicket-ui-resize
Maven Repository/Dependency of Group ID org.wicketstuff and Artifact ID wicketstuff-jwicket-ui-resize. Latest version of org.wicketstuff:wicketstuff-jwicket-ui-resize dependencies. # Version Release Date
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
Yahoo Auto Suggest
Yahoo Auto Suggest  Am using Yahoo Library for Auto Suggest and it is implementing well.. My Requirement is I've two radio buttons with a and b and its name is stype. When i selected a, I'll get a different suggestions
ModuleNotFoundError: No module named 'auto-all'
ModuleNotFoundError: No module named 'auto-all'  Hi, My Python... 'auto-all' How to remove the ModuleNotFoundError: No module named 'auto-all... to install padas library. You can install auto-all python with following
ModuleNotFoundError: No module named 'auto-all'
ModuleNotFoundError: No module named 'auto-all'  Hi, My Python... 'auto-all' How to remove the ModuleNotFoundError: No module named 'auto-all... to install padas library. You can install auto-all python with following
ModuleNotFoundError: No module named 'auto-api'
ModuleNotFoundError: No module named 'auto-api'  Hi, My Python... 'auto-api' How to remove the ModuleNotFoundError: No module named 'auto-api... to install padas library. You can install auto-api python with following
ModuleNotFoundError: No module named 'auto-api'
ModuleNotFoundError: No module named 'auto-api'  Hi, My Python... 'auto-api' How to remove the ModuleNotFoundError: No module named 'auto-api... to install padas library. You can install auto-api python with following
ModuleNotFoundError: No module named 'auto-api'
ModuleNotFoundError: No module named 'auto-api'  Hi, My Python... 'auto-api' How to remove the ModuleNotFoundError: No module named 'auto-api... to install padas library. You can install auto-api python with following

Ads