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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ragini Shukla
Hiiii
2 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners



Advertisement
View Answers

August 22, 2008 at 2:16 PM


hai frnd..........
on clicking the print button goto a new jsp page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c"%>
<html>
<head>
<title>SEARCH</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Rational Application Developer">
</head>
<body>

<form>
<%@ page import="java.sql.*" %>
<%! Connection con;
ResultSet rst;
Statement st;
int a=0,no_of_pages=0,int count=o;
String url="jdbc:db2://url/database:";

%>
<%
try
{
Class.forName("com.ibm.db2.jcc.DB2Driver");
con=DriverManager.getConnection(url,"db2inst2","inst123$");
System.out.println("After Establishing connection");
}
catch(ClassNotFoundException e)
{
System.out.println("ERROR!1: "+e);

}
%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@ page import="java.io.*" %>
<%try{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(1);


try
{

st=con.createStatement();
System.out.println("Before Select");
rst=st.executeQuery("select * from tablename");
System.out.println("After select");
while(rst.next())
{

row.createCell((short)1).setCellValue(rst.getInt(1));//write according to ur column datatype
row.createCell((short)2).setCellValue(rst.getString(2));//write according to ur cloumn datatype.
//write the same command for how many columns u want to save in excel
row.createCell((short)3).setCellValue(true);





FileOutputStream fileOut = new FileOutputStream
("c:\\excel\\Data.xls");
wb.write(fileOut);
fileOut.close();
}catch ( Exception ex ){
}
%>
<br>
<b>The Data is saved to Excel</b>
</form>
</bodY>
</html>


Thanks and Regards

Prashu
prashobvee@gmail.com


August 22, 2008 at 2:18 PM


hai frnd....
CLOSE THE WHILE LOOP BEFORE FileOutputStream fileOut = new FileOutputStream
("c:\\excel\\Data.xls");


Thanks and regards
Prashu
prashobvee@gmail.com


Related Tutorials/Questions & Answers:
Advertisements
RAJ9992
Servlet sending image  hiiii In my html page i use how to send this image value to servlet plz be inform me anybody
input using scanner and add/sub/mul/div of a matrix
input using scanner and add/sub/mul/div of a matrix  hiiii...... performe matrix add/sub/mul/div using scanner
RAJ9992
Send Image Value to Servlet  hiiii In my html page i use input type=image src="" value="" name="" how to send this image value to servlet plz be inform me anybody
meenakshi
meenakshi  HIIII, Any one can help me,, I have created a form in jsp and bind it by using spring:bind in spring. I have use ModelAndView of SimpleFormController . But when i called onSubmit thn onSubmit not called
login data
login data  Hiiii Sir I am doing banking project on Asp.net i have created database on sql and also created a connection to gui but m not getting the data after login i want to show particular data for particular user means if i
login data
login data   Hiiii Sir I am doing banking project on Asp.net i have created database on sql and also created a connection to gui but m not getting the data after login i want to show particular data for particular user means
error in accessing database - JSP-Servlet
error in accessing database  hiiii im tanushri im tryng to connect my database to the servlet i hv succeeded in connectivity but im stuck to nother error called Got minus one from read call although i hv feeded data to my
error got minus one from read call - JSP-Servlet
error got minus one from read call  hiiii while connecting my servlet to database im getting error called java.sql.SQLException: Io exception: Got minus one from a read call oracle.jdbc.dbaccess.DBError.throwSqlException
Advertisements
 

 

 

DMCA.com