onfly conversion of jsp to pdf (urgent)



Share on Google+Share on Google+

onfly conversion of jsp to pdf (urgent)
1 Answer(s)      9 years ago
Posted in : Development process
View Answers

September 29, 2008 at 6:37 PM



In this code having a button "Create Pdf" onClick this button call
method showEmp(); then it send to the url on the proccess page
var url="getuser.jsp?emp_id=E01";

it passes emp_id to "getuser.jsp" and on this page create a Pdf file on th
c:drive with "hello.pdf".

<%@ page import="java.sql.*" %>
A:hover {text-decoration: none;

border: 0px;
color: #2d2b2b; }

<link rel="stylesheet" type="text/css" href="datepicker.css"/>

<script type="text/javascript">
function trim(str) {
if(!str || typeof str != 'string')
return null;
return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
function showEmp()

if (xmlHttp==null)
alert ("Browser does not support HTTP Request")
var url="getuser.jsp?emp_id=E01";


function stateChanged()

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

var showdata = xmlHttp.responseText;
if(trim(showdata) =="ok")
alert("You are successful create the pdf");


function GetXmlHttpObject()
var xmlHttp=null;
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
catch (e)
//Internet Explorer
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
catch (e)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;

<body >
<tr><td><input type="button" name="result" id="result" value="Create Pdf" onclick="showEmp();"></td></tr>



<%@ page import="java.sql.*,java.io.*,com.lowagie.text.pdf.*,com.lowagie.text.*,com.lowagie.text.Document
" %>
String emp_id = request.getParameter("emp_id").toString();
String data ="";

Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

int sumcount=0;
Statement st;
try {

conn = DriverManager.getConnection(url+dbName,userName,password);
String query = "select * from employee_details where eid='"+emp_id+"'";

st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
data = rs.getString(2) + " " + rs.getString(3);

Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("c:\\hello.pdf"));
document.add(new Paragraph(data));

catch (Exception e) {



Related Tutorials/Questions & Answers:
onfly conversion of jsp to pdf (urgent) - Development process
onfly conversion of jsp to pdf (urgent)  Hi, i m facing problem to convert jsp to pdf on on fly, i have an application in which there is some... (in PDF form) on a button click event all the text in jsp is dynamic comes from
Reports to pdf conversion
Reports to pdf conversion  I need to convert reports into pdf format using java.. Will i get any sample code
pdf to xml conversion
pdf to xml conversion  i want to convert pdf file into xml file.. where i am having a table in pdf file with some headers and some data into it. i want the headers to be the tag of xml file. how can i do that using java? please
Byte array to PDF Conversion
Byte array to PDF Conversion  Hi, Am getting a letter Format in Byte array and i have to display that in PDF.Is that possible in PHP ? If so please let me knw how should i ? I can able to display that in a word Document but i
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
pdf file in jsp
pdf file in jsp  i have a pdf, which has to be displayed in a jsp page along with some html tags, the pdf which is to be displayed shold be readonly and wont allow the uer to save too
generate pdf using jsp
generate pdf using jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
pdf generate from jsp
pdf generate from jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
Program urgent - JSP-Servlet
Please please its very urgent.. Thanks/Regards...://www.roseindia.net/jsp/implement-javascript-with-jsp.shtml Thanks
Program Urgent - JSP-Servlet
in urgent need of the coding. My requirement is as follows: Beside Enter Employee ID... automatically with the selected Employee ID and Name. Its Very Urgent.. Please send me... for more information. http://www.roseindia.net/jsp Thanks. Amardeep
urgent - JSP-Servlet
Simple Jsp and Java Example  Simple Jsp and Java Example
Download.jsp Urgent - JSP-Servlet
Download.jsp Urgent  Respected Sir/Madam, I am R.Ragavendran.. I am having a simple doubt when downloading the files through JSP..... Please send me the modified code ASAP as this goes very urgent in my case
Urgent: HttpRequest - JSP-Servlet
Urgent: HttpRequest  Hi, I want to send a http Request. Their will be another program which will receice the request process it and send back the response. Example: I have one page in which I am giving 2 numbers as input
Generating PDF reports - JSP-Servlet
Question I am try to generate a pdf report using jsp .... i want to export values stored in sql server DB on to a pdf files so please do reply its very...Generating PDF reports  Hello everyone i have submitted several
Excel / Doc to PDF conversion using Acrobat9 - Development process
Excel / Doc to PDF conversion using Acrobat9  Hi, I need to convert .xls / .doc files to .pdf files using Acrobat9. Please suggest the possible... and POI library to convert doc file into pdf file. import java.io.*; import
how to generate the pdf file with scroolbar from jsp age - JSP-Servlet
how to generate the pdf file with scroolbar from jsp age  How to generate the pdf file with scroolbar from jsp.i am not able to see the all the columns in pdf file now .it is very urgent for me plz help
pdf format - JSP-Servlet
pdf format  hi Sir, how to convert text format into PDF format. thanks & regards, vijayababu.m
Program Very Urgent.. - JSP-Servlet
Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.... reference. http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml... its most urgent.. Thanks/Regards, R.Ragavendran..   Hi friend
Programming Help URGENT - JSP-Servlet
R.Ragavendran. I am in urgent need of the coding. My requirement is as follows: Beside... URGENT...://www.roseindia.net/jsp/implement-javascript-with-jsp.shtml Thanks
JSP and AJAX- very urgent - Ajax
JSP and AJAX- very urgent  Respected Sir/Madam, I am Ragavendran.. I have a simple doubt.. At present, I am in a module of the project... Plz its very very Urgent.. Regards, Ragavendran
Download.jsp Urgent plz - JSP-Servlet
Download.jsp Urgent plz  Respected Sir/Madam, I am R.Ragavendran.. I got your coding for download.jsp.. A lot of Thanks... reference: Download.JSP: file download in jsp File
JSP and AJAX very urgent - Ajax
JSP and AJAX very urgent  Hi Team, This is Ragavendran.R.. I..., there will be tag involved in JSP page. But in my current project, I am using too many tags in my JSP page and as a result, I am getting only the last div tag updated
how to generate the pdf report from jsp
want to generate the pdf file from jsp page.I add the itext.jar to the libraries...how to generate the pdf report from jsp  <%@page import... not getting the pdf file.Any one please help me asap.Its very important
Generate pdf file - JSP-Servlet
Generate pdf file   Hi Friends, How to generate the pdf file for the jsp page or in servets  Hi Friend, You need to download itext api. After that set the classpath and try the following code
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks... details from database using JDBC and JSP. The home page i.e HTML Page must contain... to ROSEINDIA team.. This is Very Urgent. Plz Plz send me the coding ASAP
jsp to struts 2 action conversion problem - Struts
jsp to struts 2 action conversion problem  i have one jsp page that includes 3 other jsp pages(using RequestDispactcher).how to convert that jsp page to a struts2 action?among that one jsp page is wrritten using jpivot,wct tags
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Download in JSP.. In the Admin window, There must be "Upload" provision where admin... Ragavendran, i am sending code of file download in jsp. Plz implement this code
Basic problem but very urgent - JSP-Servlet
kind reference. http://www.roseindia.net/jsp/popup-window-using-ajax... me the cause of the problem asap because its most urgent.. Thanks/Regards
PDF creation in JAVA - JSP-Servlet
PDF creation in JAVA  HI! Good morning.... I want to create pdf file and i want to write something into pdf file....before creation. Upto creation i have done but how to write data into pdf. File Writer is not working
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying... status - 404. How can i resolve it in JSP


Advertisement null