Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.97 KB | None | 0 0
  1. jsp code--->html responce
  2. -------------------------------------------
  3.  
  4. <%@page import="java.sql.*" %>
  5. <html>
  6. <link rel="stylesheet" type="text/css" href="style1.css"/>
  7. <body style="margin-left:15px">
  8. <div id="main_container">
  9. <table><tr><td><img src="g.jpg" style="margin-top:5px;margin-left:100px;"width="100" height="80"></td>
  10. <td>
  11. <center> <span><font size="4px" style="bgcolor:black;color:orange"><h1><b>Gatik Business Solutions Pvt Ltd</b></h1></font></span></center></td>
  12. </tr></table>
  13. <center>
  14.  
  15. <%!String ma; %>
  16. <%
  17.  
  18. Object obj=session.getAttribute("uname");
  19.  
  20. Object m=session.getAttribute("month");
  21. Object amount=session.getAttribute("amount");
  22. String uid=(String)obj;
  23. String month=(String)m;
  24. // out.println(uid);
  25. // out.println(month);
  26. try
  27. {
  28. Class.forName("oracle.jdbc.driver.OracleDriver");
  29.  
  30. Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "sree");
  31. // System.out.println("in connection");
  32.  
  33.  
  34. Statement st=con.createStatement();
  35. Statement st1=con.createStatement();
  36. // 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"+
  37. // "from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' ";
  38.  
  39.  
  40. // 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"+
  41. // "from customer_register c,months_bills b where c.user_id='cnr' and b.user_id='cnr';
  42.  
  43. // and to_char(b.bill_date ,'mon')='"+month+"' and b.month='"+month+"'
  44. //and to_char(b.bill_date ,'mon-yyyy')='"+month+"' and b.month='"+month+"'
  45.  
  46. ResultSet rs1=st1.executeQuery("select amount from customer_register where user_id='"+uid+"'");
  47. if(rs1.next()){
  48. ma=rs1.getString(1);
  49. }
  50. 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+"' ");
  51.  
  52. if(rs.next()){
  53. Float f=Float.parseFloat(rs.getString(5));
  54.  
  55. %>
  56.  
  57. <div align="center" dir="ltr" >
  58. <div align="right" ><h3>
  59.  
  60. <font color="red" style="margin-right:17%" "><b>Customer bill No:&nbsp;&nbsp;</b><%=rs.getString(1) %></font><br/>
  61. <font color="red" style="margin-right:17%"><b>Bill Date:&nbsp;&nbsp;</b><%=rs.getString(6) %></font>
  62. </h3>
  63. </div>
  64. <br/><br/>
  65. <table>
  66. <tr><td>Customer Name:</td><td><%=rs.getString(3) %></td></tr><tr></tr>
  67. <tr><td>Customer Id:</td><td><%=rs.getString(2) %></td></tr><tr></tr>
  68.  
  69. <tr><td>Customer package(plan):</td><td><%=rs.getString(4) %></td></tr><tr></tr>
  70. <tr><td>Operator Name :</td><td><%=rs.getString(9) %></td></tr><tr></tr>
  71. <tr><td>Paid Date :</td><td><%=rs.getString(6) %></td></tr><tr></tr>
  72. <tr><td>Current Month Bill Amount (Rs):</td><td><%=ma %></td></tr><tr></tr>
  73. <tr><td>Previous Month due (Rs):</td><td><%=(Float)amount-f %></td></tr><tr></tr>
  74. <tr><td>Amount paid Now</td><td><%=(Float)amount %></td></tr>
  75. <tr><td>Excess Amount paid by Customer:&nbsp;&nbsp;</td><td><%=rs.getString(7) %></td></tr><tr></tr>
  76. <tr><td>Less Amount Paid by Customer:</td><td><%=rs.getString(8) %></td></tr><tr></tr>
  77.  
  78. <tr></tr>
  79. <tr></tr>
  80. <tr><td></td><td></td><td> <DIV ALIGN="right"><u><b>Signature</b></u></DIV></td></tr>
  81. <tr><td></td></tr>
  82. </table></div>
  83. </center>
  84.  
  85. <%
  86. }
  87. }
  88. catch(SQLException e)
  89. {
  90. e.printStackTrace();
  91. }
  92. %>
  93. <center>
  94. <SCRIPT LANGUAGE="JavaScript">
  95. if (window.print) {
  96. document.write('<form><input type=button name=print value="Print" onClick="window.print()"></form>');
  97. }
  98. </script>
  99.  
  100. <form action="MakePaymentOutPutpdff.jsp">
  101. <input type="submit" value="save"/>
  102. </form>
  103. <form action="MakePaymentEmail.jsp">
  104. <input type="submit" value="email"/>
  105. </form>
  106. </center>
  107. </div>
  108. </body>
  109. </html>
  110.  
  111. ---------------------------------------------------------------------------
  112. jsp with pdf responce
  113. -------------------------
  114. <%@page import="java.io.*" %>
  115. <%@page import="java.sql.*" %>
  116. <%@page import="com.itextpdf.text.Document"%>
  117. <%@page import="org.apache.commons.io.output.ByteArrayOutputStream"%>
  118. <%@page import="com.itextpdf.text.pdf.PdfWriter"%>
  119. <%@page import="com.itextpdf.text.Paragraph"%>
  120. <%@page import="com.itextpdf.text.Phrase"%>
  121. <%@page import="com.itextpdf.text.Element"%>
  122. <%@page import="com.itextpdf.text.pdf.PdfPTable"%>
  123. <%@page import="com.itextpdf.text.pdf.PdfPCell"%>
  124. <%@page import="com.itextpdf.text.Font"%>
  125. <%@page import="com.itextpdf.text.Font.FontFamily"%>
  126. <%@page import="com.itextpdf.text.*"%>
  127. <html>
  128. <link rel="stylesheet" type="text/css" href="style1.css"/>
  129. <body style="margin-left:15px">
  130. <div id="main_container">
  131. <center> <font style="bgcolor:black;color:orange"><h2><b>Gatik link Broadband services......</b></h2></font><br><br></center>
  132. <img src="g.jpg" style="margin-top:-10px;margin-left:100px;"width="100" height="100">
  133. <center>
  134.  
  135. <%!String ma; %>
  136. <%
  137. response.setContentType("application/pdf");
  138. Object obj=session.getAttribute("uname");
  139.  
  140. Object m=session.getAttribute("month");
  141. Object amount=session.getAttribute("amount");
  142. String uid=(String)obj;
  143. String month=(String)m;
  144. // out.println(uid);
  145. // out.println(month);
  146. try
  147. {
  148. Class.forName("oracle.jdbc.driver.OracleDriver");
  149.  
  150. Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "sree");
  151. // System.out.println("in connection");
  152.  
  153.  
  154. Statement st=con.createStatement();
  155. Statement st1=con.createStatement();
  156. // 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"+
  157. // "from customer_register c,months_bills b where c.user_id='"+uid+"' and b.user_id='"+uid+"' ";
  158.  
  159.  
  160. // 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"+
  161. // "from customer_register c,months_bills b where c.user_id='cnr' and b.user_id='cnr';
  162.  
  163. // and to_char(b.bill_date ,'mon')='"+month+"' and b.month='"+month+"'
  164. //and to_char(b.bill_date ,'mon-yyyy')='"+month+"' and b.month='"+month+"'
  165.  
  166. ResultSet rs1=st1.executeQuery("select amount from customer_register where user_id='"+uid+"'");
  167. if(rs1.next()){
  168. ma=rs1.getString(1);
  169. }
  170. 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+"' ");
  171.  
  172. if(rs.next()){
  173. Float f=Float.parseFloat(rs.getString(5));
  174.  
  175. %>
  176.  
  177. <%
  178.  
  179. Document doc = new Document();
  180.  
  181. //ByteArrayOutputStream buffer=new ByteArrayOutputStream();
  182. PdfWriter writer= PdfWriter.getInstance(doc,response.getOutputStream());
  183. String s="nag";
  184. PdfWriter.getInstance(doc,new FileOutputStream("d://Payment.pdf"));
  185. //ZipOutputStream zip =new ZipOutputStream(new FileOutputStream(""));
  186. doc.open();
  187.  
  188. //writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));
  189. Image image = Image.getInstance("d://g.jpg");
  190. image.setAlignment(Image.ALIGN_LEFT);
  191. image.getAbsoluteX();
  192. image.scaleAbsolute(70f, 40f);
  193. doc.add(image);
  194. Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 23);
  195. doc.add(new Phrase(" Gutik Business Solutions Pvt Ltd",font1));
  196.  
  197.  
  198. Rectangle rc=new Rectangle(50f,50f,50f,50f);
  199. rc.getBorder();
  200. rc.getBackgroundColor();
  201. doc.add(rc);
  202. PdfPTable table1 = new PdfPTable(1);
  203. table1.setHorizontalAlignment(Element.ALIGN_BOTTOM);
  204. PdfPCell cell = new PdfPCell(new Paragraph(""));
  205. table1.addCell(cell);
  206. table1.setWidthPercentage(100);
  207. cell.setLeading(20f, 0f);
  208. doc.add(table1); // 3 columns.
  209. /*
  210. //doc.add(image);
  211. PdfPTable table1 = new PdfPTable(2); // 3 columns.
  212. float[] columnWidths = {1f, 2f};
  213. table1.setWidths(columnWidths);
  214. table1.setWidthPercentage(100);
  215. PdfPCell cell1 = new PdfPCell(image, true);
  216. cell1.setLeading(20f, 0f);
  217. cell1.setBorderWidth(0f);
  218. // Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 17);
  219. PdfPCell cell2 = new PdfPCell(new Paragraph("Gutik Business Solutions Pvt Ltd",font1));
  220. cell2.setLeading(20f, 0f);
  221. cell2.setHorizontalAlignment(Element.ALIGN_BOTTOM);
  222. cell2.setBorderWidth(0f);
  223. table1.addCell(cell1);
  224. table1.addCell(cell2);
  225. */
  226. //doc.add(table1);
  227.  
  228.  
  229. doc.close();
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242. }
  243. }
  244. catch(SQLException e)
  245. {
  246. e.printStackTrace();
  247. }
  248. %>
  249.  
  250.  
  251.  
  252. </body>
  253. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement