How to print report in jsp page?

excuse me,i am new to jsp
may i know how to pritn report in jsp page or html?
tq

here is a hacked up example.. i ripped out a lot, so it may not compile, but you get the idea... the full version is really long and not much new info.. just all awt/display stuff...
package rowe;
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.sql.*;
import utility.*;
import java.awt.print.*;
public class rowePrint extends JFrame implements ActionListener, Printable{
     String printType = "";
     static JButton j = new JButton("Print");
     FontMetrics fm;
     String jID, promotion, product, jComments;
     public void getInfo(int jid) {
          ResultSet rs;
          try {
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection conn = DriverManager.getConnection("jdbc:odbc:rowe");
               Statement stmt = conn.createStatement();
               rs = stmt.executeQuery("select j.id as jID, j.comments, p.title as pTitle, p.product, p.packagingCartonCost, p.foldingQuarterCostPerM, p.foldingQuarterCostPerM, j.customizationOption as setupFee, p.perMcost, p.qtyCarton, d.name as dName, d.contact as dContact, d.email as dEmail, d.address as dAddress, d.city as dCity, d.state as dState, d.zip as dZip, d.phone as dPhone, d.fax as dFax, r.name as rName, j.totalQty, j.orderIn, j.estFreight, j.miscCost, j.coverSelection, j.imprintSelection from jobs j, promotions p, dealers d, reps r where j.promotion = p.id and j.dealer = d.id and j.rep = r.id and j.id = " + jid);
               rs.next();
               jID = rs.getString("jID");
               jComments = rs.getString("comments");
               promotion = rs.getString("pTitle");
               product = rs.getString("product");
          } catch (Exception e) {
               System.out.println("getinfo: " + e);
   public void actionPerformed(ActionEvent e) {
        if (e.getSource() instanceof JButton) {  
               wookie();
     public void wookie() {
          PrinterJob printJob = PrinterJob.getPrinterJob();
          Paper paper = new Paper();
          PageFormat page = new PageFormat();
          paper.setImageableArea(0, 0, 600, 780);            
          page.setPaper(paper);
          printJob.setPrintable(this, page);
          try{
               //printJob.pageDialog(page);
          //     if (printJob.printDialog()) {
                    printJob.print();
          } catch (Exception e) {
               System.out.println("wookie1" + e);
     public static void main(String[] args) {
          rowePrint at = new rowePrint("Invoice");
          at.getInfo((new Integer(args[0])).intValue());
          at.drawShapes();
     //     at.wookie();
     public void drawShapes() {
          setBounds(0, 0, 670, 550);
          addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});
          j.setBounds(10, 10, 10, 10);
          j.addActionListener(this);
          getContentPane().setLayout(null);
          getContentPane().add(l);
          getContentPane().add(j);
          show();
     public rowePrint(String s){
          printType = s;
     public void paint(Graphics g) {
          g.setFont(new Font("Serif", Font.BOLD, 18));
          g.drawString(promotion, 20, 30);
          g.setFont(new Font("SansSerif", Font.PLAIN, 4));
          g.drawString("" + new java.util.Date(), 20, 37);
          g.setFont(new Font("Serif", Font.BOLD, 21));
          g.drawString("Rowe Furniture", 440, 35);
          g.fillRect(440, 40, 145, 25);
          g.setColor(Color.white);
          fm = g.getFontMetrics(new Font("Serif", Font.BOLD, 21));
          g.drawString(printType, 512 - (fm.stringWidth(printType) / 2), 60);
    public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
        if (pi >= 1) {
            return Printable.NO_SUCH_PAGE;
          paint(g);
        return Printable.PAGE_EXISTS;
}

Similar Messages

  • How to print report from JSP Page

    Hi Everybody,
    I am developing a simple project in JSP with MS Access. I hav some tables and reports for them. I hav a JSP page which gets inputs from user and save it in the table. Its working fine. But my problems are,
    1) I hav a button called "SAVE & PRINT" in that bottom of the page, if i click that button, the currently entered data has to save in the table and the same data has to print from the MS Access report. I dont know how to print this report from JSP page.
    2) Another button called "REPRINT". If i click that button, it has to ask a number to print the report page, that number is nothing but a field in that report.
    Could anyone help me to solve this problem.

    Hi Everybody,
    I am developing a simple project in JSP with MS Access. I hav some tables and reports for them. I hav a JSP page which gets inputs from user and save it in the table. Its working fine. But my problems are,
    1) I hav a button called "SAVE & PRINT" in that bottom of the page, if i click that button, the currently entered data has to save in the table and the same data has to print from the MS Access report. I dont know how to print this report from JSP page.
    2) Another button called "REPRINT". If i click that button, it has to ask a number to print the report page, that number is nothing but a field in that report.
    Could anyone help me to solve this problem.

  • Hyperion Anaylzer - how to Print report with information in pages?

    Hi,<BR><BR>I use Hyperion Analyzer Version: 6.1.1.00206 (from Help | About menu).<BR><BR>I created report with pages (on Navigate button selected the Pages). In pages are months (January, February, March, etc).<BR><BR>Now I would like to print current report. So I did:<BR>1. click on arrow beside Print button<BR>2. Print Current Report windows is displayed. I selected default options and press OK button.<BR><BR>Report is printed, but there is no page information printed out. So on paper there is report without months (January, February, March, etc).<BR><BR>How to print report with information in pages?<BR><BR>Thanks,<BR>Grofaty

    Jia Shun,
    I had the same issue for printing A/R Invoices - I created a Crystal Report based on a SQL View, works fine with A/R Invoice document, but the Draft Invoice printing has 3 pages: 1st page blank, 2nd page with watermark "DRAFT", 3rd page my Crystal Report layout without any data. When printing normally it is only 1 page.
    Here is what I did as a work around:
    Create two SQL Views, one select from OINV (joining INV1 and other tables needed), the other select from ODRF (joining DRF1 and other tables needed), for the draft printing.
    Create two identicle Crystal Reports, only difference are: datasource location (from different views), the "draft" crystal report has a watermark section.
    Go to Administration>System Initialization>Print Preferences and uncheck "Print draft watermark..."
    Import both crystal reports. Invoice can be printed normally. But the Draft Invoice has more steps: Open Draft document report, change settings so it shows the DocEntry in the Draft Table. Select and open the desired document, hit Print Preview, and enter the DocEntry, it displays the layout with data and "DRAFT" watermark.
    This is a workaround. I don't like it because it is not scalable - too much workload if you want to print 100 invoices.
    Hopefully someone will provide a better solution.
    regards,
    G

  • How to call RDF report from JSP page

    Dear all,
    I want to call a RDF report from JSP page. I am creating the JSP page using j developer 10G.
    Can anyone help me out in this case. Is there any tag or procedure or any other way by of that i can perform this work.
    please help and send the reply on [email protected],[email protected]
    thanks
    Ashok

    Hi Ashok,
    You can use rwservlet - nothing really to do with JDeveloper. Once you have report server up and running (hint: read http://download-uk.oracle.com/docs/cd/B14099_19/bi.1012/b14048/toc.htm), you can call a report like this:
    http://server:port/rwservlet?report=my_report.rdf&destype=cache&desformat=html&p_my_parameter=xxx etcHope this helps,
    John

  • How to call the crystal report in jsp page

    dear friends
    i want to run or call the crystal report in jsp page.
    if u know that can u send sample code for that to my id
    [email protected]

    Hi Sudhakar,
    Could you please be more speicific about the task you want to accomplish?
    Cheers
    Giri :-)

  • View jasper report in jsp page

    i have developed a java code that could connect to the databse n compile xml code into jasper report. report is generated when it is executed in dos prompt. however i wan the report to appear after a button "print" in a jsp page is pressed. how do i do dat? how do i ask my jsp page to execute my curret java code to generate a report?

    same

  • How to print an envelope in pages 5.0

    How to print an envelope in pages 5.0

    I'm away from my computer right now but I believe there is a template for that.
    Click New, select new from template, it should be there...
    Alexis

  • Re : how to print report output in DOT MATRIX printer

    Hai
           how to print report output in DOT MATRIX printer.
    Thanks
    mani

    Check this
    [http://help.sap.com/saphelp_nw04/helpdata/en/90/78f078030211d399b90000e83dd9fc/frameset.htm]
    also check the SAP Note 129581

  • How to do transactions in jsp pages using Java & MySQL ?

    Hi,
    I'm a newbie..
    I'd like to know "How to do transactions in jsp pages using Java & MySQL ?"
    Platform: Windows XP, Apache Tomcat 5.5, MySQL 5, Java bean without EJB
    what are the the different types of transactions? Differences between them?Pls provide examples?
    Which among them is the best method to implement a transaction?
    Pls help me...
    thnx in advance...

    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • How to develop and Run .jsp page from Jdeveloper 10g

    Dear All,
    I need to develop one small JSP page using Jdeveloper10g. pls share information How to develop and Run .jsp page from Jdeveloper 10g.
    Thanks in Advance,
    Hanimi.

    Hi Gyan,
    Any Idea how to get DB connection for JSP Pages.
    Our Java guys developed one JSP page for Login page.
    After Log in instead of standard responsibilites page we calling custom jsp page, For getting DB connection they defined one properties file and hard coded DB details on that file and calling, but client is not accepting hard coding.
    Pls give any idea for getting DB connection directly in JSP pages.
    Hanimi.

  • HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH

    Hi,
    HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH?
    Thanks

    emekaco wrote:
    Hi,
    HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH?
    ThanksSTOP SHOUTING!
    now, while displaying the form generate some random number, or take the current time in millis or whatever. Put that number in a hidden field. Insert that unique number along with the real data into the database, but before you do check if the number already exists. If it does you can be pretty sure this is a resubmit of the same data, so don't allow it. This is one way of many to prevent resubmission of existing data.
    A good way to prevent a refresh from resubmitting altogether is to do a redirect to a result page right after you deal with the POST request. When the user presses refresh then, he/she will refresh the redirect and not the form submit.

  • How to set title of jsp page from resource bundle

    hi ,
    How to set title of jsp page from resource bundle....

    Depends on how you configured and declared the resourcebundle in your JSP. The usual way is just<title>${resourceBundle.messageKey}</title>

  • How user can change password @ jsp page

    [att1.html]
              

    Try http://dev2dev.bea.com/codelibrary/code/pwchange.jsp
              It is for 8.1, but it can be a good starting point
              <[email protected]> wrote in message news:[email protected]..
              How i can develop a jsp page that let user change their login password that stored in reaml residered at WebLogic 7.0 srever.
              Thanks in advance.
              [att1.html]
              

  • How i start printing report from 2nd page

    When Press on Print button to print report, then it start from 1 page.
    Is it possible that report start printing from the 2nd page....
    Plz help if possible...
    Thanks alot..

    hi dear,
    I think wht u do is place a "Form feed" char on the first line of your report
    and make sure it has property "print object on" set to "first page"
    so as and when u startyour printing it will make a form feed and your first page will
    be printed with nothing and print starts from 2nd page....
    Enjoy Oracle...

Maybe you are looking for

  • Reference for Connecting EJB in KM scheduler Task

    Hi,        What are the main References we need to add portalapp.xml,when we connect Ejb in Km scheduler Tasks For Example: portalapp.xml <?xml version="1.0" encoding="UTF-8"?>   <application >     <application-config>     <property name="SharingRefe

  • I have got problem with "Date & Time"

    I have bought a new Macbook Air 13" I have chosen "set date & time auto..." However, it shows in up right corner wrong date. Also all mail, reminders and etc work with wrong date. Please, tell me what to do with this problem. Sincerelly, Mark

  • Is the iPhone 5 compatible with the Audi Music Interface (AMI) system in my car?

    I have a 2011 Audi A4 and I'm wondering if the iPhone 5 will work with car's audio system if I use the 30-pin to Lightning adapter. Will I be able to control my music with the steering wheel and have visibility to tracks, etc. on the dash display as

  • Pages won't create docs on Xserve G5

    I've downloaded and installed the demo of iWork '08 twice and have the same results. Pages will open but I cannot get the template chooser to come up, nor can I enter any text in a blank document. Additionally, the menus are either slow or incomplete

  • Genuine Software Verification Failure for Captivate 8

    Hello, I am curious about an error that keeps on occurring with the trial download of Captivate 8. I am working on a Company Machine, a Dell Precision Tower 7910, and I need to download a trial of Adobe Captivate 8. Upon the install it reaches 99% an