Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jsp code--->html responce
- -------------------------------------------
- <%@page import="java.sql.*" %>
- <html>
- <link rel="stylesheet" type="text/css" href="style1.css"/>
- <body style="margin-left:15px">
- <div id="main_container">
- <table><tr><td><img src="g.jpg" style="margin-top:5px;margin-left:100px;"width="100" height="80"></td>
- <td>
- <center> <span><font size="4px" style="bgcolor:black;color:orange"><h1><b>Gatik Business Solutions Pvt Ltd</b></h1></font></span></center></td>
- </tr></table>
- <center>
- <%!String ma; %>
- <%
- Object obj=session.getAttribute("uname");
- Object m=session.getAttribute("month");
- Object amount=session.getAttribute("amount");
- String uid=(String)obj;
- String month=(String)m;
- // out.println(uid);
- // out.println(month);
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "sree");
- // System.out.println("in connection");
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- // String sql="select c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy hh24:mi:ss'),b.extra_amount ,b.balance_amount,c.operator"+
- // "from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' ";
- // select c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy hh24:mi:ss'),b.extra_amount ,b.balance_amount,c.operator"+
- // "from customer_register c,months_bills b where c.user_id='cnr' and b.user_id='cnr';
- // and to_char(b.bill_date ,'mon')='"+month+"' and b.month='"+month+"'
- //and to_char(b.bill_date ,'mon-yyyy')='"+month+"' and b.month='"+month+"'
- ResultSet rs1=st1.executeQuery("select amount from customer_register where user_id='"+uid+"'");
- if(rs1.next()){
- ma=rs1.getString(1);
- }
- ResultSet rs=st.executeQuery("select b.sno, c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy'),b.extra_amount ,b.balance_amount,c.operator from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' and b.bill_date=(select max(bill_date)from months_bills where user_id='"+uid+"') and b.month='"+month+"' ");
- if(rs.next()){
- Float f=Float.parseFloat(rs.getString(5));
- %>
- <div align="center" dir="ltr" >
- <div align="right" ><h3>
- <font color="red" style="margin-right:17%" "><b>Customer bill No: </b><%=rs.getString(1) %></font><br/>
- <font color="red" style="margin-right:17%"><b>Bill Date: </b><%=rs.getString(6) %></font>
- </h3>
- </div>
- <br/><br/>
- <table>
- <tr><td>Customer Name:</td><td><%=rs.getString(3) %></td></tr><tr></tr>
- <tr><td>Customer Id:</td><td><%=rs.getString(2) %></td></tr><tr></tr>
- <tr><td>Customer package(plan):</td><td><%=rs.getString(4) %></td></tr><tr></tr>
- <tr><td>Operator Name :</td><td><%=rs.getString(9) %></td></tr><tr></tr>
- <tr><td>Paid Date :</td><td><%=rs.getString(6) %></td></tr><tr></tr>
- <tr><td>Current Month Bill Amount (Rs):</td><td><%=ma %></td></tr><tr></tr>
- <tr><td>Previous Month due (Rs):</td><td><%=(Float)amount-f %></td></tr><tr></tr>
- <tr><td>Amount paid Now</td><td><%=(Float)amount %></td></tr>
- <tr><td>Excess Amount paid by Customer: </td><td><%=rs.getString(7) %></td></tr><tr></tr>
- <tr><td>Less Amount Paid by Customer:</td><td><%=rs.getString(8) %></td></tr><tr></tr>
- <tr></tr>
- <tr></tr>
- <tr><td></td><td></td><td> <DIV ALIGN="right"><u><b>Signature</b></u></DIV></td></tr>
- <tr><td></td></tr>
- </table></div>
- </center>
- <%
- }
- }
- catch(SQLException e)
- {
- e.printStackTrace();
- }
- %>
- <center>
- <SCRIPT LANGUAGE="JavaScript">
- if (window.print) {
- document.write('<form><input type=button name=print value="Print" onClick="window.print()"></form>');
- }
- </script>
- <form action="MakePaymentOutPutpdff.jsp">
- <input type="submit" value="save"/>
- </form>
- <form action="MakePaymentEmail.jsp">
- <input type="submit" value="email"/>
- </form>
- </center>
- </div>
- </body>
- </html>
- ---------------------------------------------------------------------------
- jsp with pdf responce
- -------------------------
- <%@page import="java.io.*" %>
- <%@page import="java.sql.*" %>
- <%@page import="com.itextpdf.text.Document"%>
- <%@page import="org.apache.commons.io.output.ByteArrayOutputStream"%>
- <%@page import="com.itextpdf.text.pdf.PdfWriter"%>
- <%@page import="com.itextpdf.text.Paragraph"%>
- <%@page import="com.itextpdf.text.Phrase"%>
- <%@page import="com.itextpdf.text.Element"%>
- <%@page import="com.itextpdf.text.pdf.PdfPTable"%>
- <%@page import="com.itextpdf.text.pdf.PdfPCell"%>
- <%@page import="com.itextpdf.text.Font"%>
- <%@page import="com.itextpdf.text.Font.FontFamily"%>
- <%@page import="com.itextpdf.text.*"%>
- <html>
- <link rel="stylesheet" type="text/css" href="style1.css"/>
- <body style="margin-left:15px">
- <div id="main_container">
- <center> <font style="bgcolor:black;color:orange"><h2><b>Gatik link Broadband services......</b></h2></font><br><br></center>
- <img src="g.jpg" style="margin-top:-10px;margin-left:100px;"width="100" height="100">
- <center>
- <%!String ma; %>
- <%
- response.setContentType("application/pdf");
- Object obj=session.getAttribute("uname");
- Object m=session.getAttribute("month");
- Object amount=session.getAttribute("amount");
- String uid=(String)obj;
- String month=(String)m;
- // out.println(uid);
- // out.println(month);
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "sree");
- // System.out.println("in connection");
- Statement st=con.createStatement();
- Statement st1=con.createStatement();
- // String sql="select c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy hh24:mi:ss'),b.extra_amount ,b.balance_amount,c.operator"+
- // "from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' ";
- // select c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy hh24:mi:ss'),b.extra_amount ,b.balance_amount,c.operator"+
- // "from customer_register c,months_bills b where c.user_id='cnr' and b.user_id='cnr';
- // and to_char(b.bill_date ,'mon')='"+month+"' and b.month='"+month+"'
- //and to_char(b.bill_date ,'mon-yyyy')='"+month+"' and b.month='"+month+"'
- ResultSet rs1=st1.executeQuery("select amount from customer_register where user_id='"+uid+"'");
- if(rs1.next()){
- ma=rs1.getString(1);
- }
- ResultSet rs=st.executeQuery("select b.sno, c.user_id,c.cust_name,c.package_name,b.amount,to_char(b.bill_date ,'dd-mon-yyyy'),b.extra_amount ,b.balance_amount,c.operator from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' and b.bill_date=(select max(bill_date)from months_bills where user_id='"+uid+"') and b.month='"+month+"' ");
- if(rs.next()){
- Float f=Float.parseFloat(rs.getString(5));
- %>
- <%
- Document doc = new Document();
- //ByteArrayOutputStream buffer=new ByteArrayOutputStream();
- PdfWriter writer= PdfWriter.getInstance(doc,response.getOutputStream());
- String s="nag";
- PdfWriter.getInstance(doc,new FileOutputStream("d://Payment.pdf"));
- //ZipOutputStream zip =new ZipOutputStream(new FileOutputStream(""));
- doc.open();
- //writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));
- Image image = Image.getInstance("d://g.jpg");
- image.setAlignment(Image.ALIGN_LEFT);
- image.getAbsoluteX();
- image.scaleAbsolute(70f, 40f);
- doc.add(image);
- Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 23);
- doc.add(new Phrase(" Gutik Business Solutions Pvt Ltd",font1));
- Rectangle rc=new Rectangle(50f,50f,50f,50f);
- rc.getBorder();
- rc.getBackgroundColor();
- doc.add(rc);
- PdfPTable table1 = new PdfPTable(1);
- table1.setHorizontalAlignment(Element.ALIGN_BOTTOM);
- PdfPCell cell = new PdfPCell(new Paragraph(""));
- table1.addCell(cell);
- table1.setWidthPercentage(100);
- cell.setLeading(20f, 0f);
- doc.add(table1); // 3 columns.
- /*
- //doc.add(image);
- PdfPTable table1 = new PdfPTable(2); // 3 columns.
- float[] columnWidths = {1f, 2f};
- table1.setWidths(columnWidths);
- table1.setWidthPercentage(100);
- PdfPCell cell1 = new PdfPCell(image, true);
- cell1.setLeading(20f, 0f);
- cell1.setBorderWidth(0f);
- // Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 17);
- PdfPCell cell2 = new PdfPCell(new Paragraph("Gutik Business Solutions Pvt Ltd",font1));
- cell2.setLeading(20f, 0f);
- cell2.setHorizontalAlignment(Element.ALIGN_BOTTOM);
- cell2.setBorderWidth(0f);
- table1.addCell(cell1);
- table1.addCell(cell2);
- */
- //doc.add(table1);
- doc.close();
- }
- }
- catch(SQLException e)
- {
- e.printStackTrace();
- }
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement