Need help for printer application status

Hi,
I am using jdeveloper11.1.1.2.0.Actually standalone java application,I want to know status of the printer,If there is no paper inside printer then message should be display no paper in the printer,
if i did printout but after 2 second i want to cancel the print then message should be also display ...
my code is below..
public void invokePrintJob(ActionEvent actionEvent) {
// Add event code here...
PrintService[] printers = PrintServiceLookup.lookupPrintServices(null, null);
Boolean printerFound = false;
for (int i = 0; i < printers.length && !printerFound; i++) {
if (printers.getName().equalsIgnoreCase(getSelectedPrinter())) {
printerFound = true;
PrintService printer = printers[i];
UploadedFile file = getTheFile();
String fileName = getTheFile().getFilename();
// String file = getTheFile();
//PrintJobAdapter pr = new PrintJobAdapter();
InputStream input;
try {
input = new BufferedInputStream((file.getInputStream()));
Doc doc = new SimpleDoc(input, DocFlavor.INPUT_STREAM.PNG, null);
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
attrs.add(new Copies(2));
attrs.add(OrientationRequested.LANDSCAPE);
JobName name = new JobName(fileName ,null);
attrs.add(name);
DocPrintJob job = printer.createPrintJob();
PrintJobWatcher pjDone = new PrintJobWatcher(job);
job.print(doc, attrs);
pjDone.waitForDone();
System.out.println("--------jobRunning-end----------");
input.close();
} catch (PrintException e) {
System.out.println(e.getMessage());
addFacesErrorMessage(e.getMessage());
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
addFacesErrorMessage(e.getMessage());
}catch (IOException ioe) {
// TODO: Add catch code
ioe.printStackTrace();
public static class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;
PrintJobWatcher(DocPrintJob job) {
// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent pje) {
System.out.println("-------printJobCanceled--------");
allDone();
public void printJobCompleted(PrintJobEvent pje) {
System.out.println("------printJobCompleted---------");
allDone();
public void printJobFailed(PrintJobEvent pje) {
System.out.println("----------printJobFailed-------");
allDone();
public void printJobNoMoreEvents(PrintJobEvent pje) {
System.out.println("--------printJobNoMoreEvents---------");
allDone();
@Override
public void printJobRequiresAttention(PrintJobEvent pje) {
System.out.println("-----------printJobRequiresAttention----------");
allDone();
@Override
public void printDataTransferCompleted(PrintJobEvent pje) {
System.out.println("-------printDataTransferCompleted---------");
allDone();
void allDone() {
// System.out.println("---------------");
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
public synchronized void waitForDone() {
try {
while (!done) {
wait(1000);
} catch (InterruptedException e) {
e.printStackTrace();
Please help me..

Help with what? What's the actual problem?
As far the code looks horrible. This kind of logic belongs in a fitler rather than a backing bean. You use empty strings instead of nulls. You stores passwords plain and unhashed in DB. You compares the password in Java instead of in DB. You stores password in a cookie. Your query is unsafe for SQL injections. You're reloading the driver class everytime when you acquire the connection. You're leaking DB connections. The application will crash sooner or later when the DB run out of connections.
Is that all what you need to know?

Similar Messages

  • Need help for printing/exporting in the right format

    Hi,
    i'm layouting a magazine for my graduation class.  And I almost finished it, but I've got a problem with printing it like I want it to be printed. I use the newest Trial Version of Adobe InDesign. The format of the magazine is A4, but when I export it as PDF (printing is the same) two pages (each A5) are exported on one horizontal A4 page. I want to have each page on one A4. Can somebody help me and say what I have to do, to get it work in my way?
    I hope you can help me, and I'm sorry if this is a silly question, but InDesign is a very complicated Software
    Thanks

    Exporting to PDF shouldn't resize the page. Does the exported PDF look the way you want it to?
    Here's all you need to know to export the file:
    File > Adobe PDF Presets > (pick a format - if you're printing from a desktop printer High Quality Print is a good choice)
    It might give you a warning about Transparency Blend Space which you can change under Edit > Transparency Blend Space
    Make sure spreads is not checked.
    If the problem is happening from Acrobat, check all of the settings in your print dialogue.
    Good luck!

  • Need HELP for MIDP application.

    i was having problems in row 45-70 and from row 88-105 which im not so sure weither i write it correctly or not.
    i wanted to do an application using MIDP where user can view question and chose the answer using List.
    The question can be get from database and the answer chose are needed to be written in text file.
    ======================================================import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class NotSoSimpleFace extends MIDlet implements CommandListener
      private Display display;
      private Command exit;
      private Command next;
      private Command finish;
      private List list;
      private int QNo=1;
      public NotSoSimpleFace()
        display = Display.getDisplay(this);
      public void startApp()
          Question(QNo);
      public void pauseApp()
      public void destroyApp(boolean unconditional)
         notifyDestroyed();
      public void commandAction(Command command, Displayable Displayable)
        if (command == next)
         boolean choice[] = new boolean[list.size()];
         list.getSelectedFlags(choice);
         for (int x = 0; x < 4; x++)
                 if (choice[x])
                   System.out.println(list.getString(x));
                //Write to Text File in Append Mode
                //..."//root1/answer.txt;append=true", Connector.WRITE
                 OutputConnection connection = (OutputConnection)                    
                 Connector.open("file:///root1/answer.txt; append=true" Connector.WRITE );
                 OutputStream out = connection.openOutputStream();
                 PrintStream output = new PrintStream( out );
                 output.println( "Answer 1 is:" + list.append(x));
                 output.println( "Answer 2 is:" + list.append(x));
                 output.println( "Answer 3 is:" + list.append(x));
                 output.println( "Answer 4 is:" + list.append(x));
                 out.close();
                 connection.close();
                   Alert alert = new Alert("Completed", "Data Written", null, null);
                 alert.setTimeout(Alert.FOREVER);
                 alert.setType(AlertType.ERROR);
                 display.setCurrent(alert);
         QNo+=1;
         if (QNo <= 4) {
              Question(QNo);
         } else {
               destroyApp(true);
        else if (command == exit)
          destroyApp(true);
      private void Question(int no)
                String url = "jdbc:odbc:MyODBC";
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             Connection c = DriverManager.getConnection(url,"","");
             Statement s = c.createStatement();
             ResultSet rs = s.executeQuery ("select Question from Question");
             while (rs.next())
              FileOutputStream fout =  new FileOutputStream("sample.txt");
             PrintStream myOutput = new PrintStream(fout);
        list = new List( myOutput.print(rs.getString(1) + "\t") + no, List.MULTIPLE);
        list.append("A", null);
        list.append("B", null);
        list.append("C", null); 
        list.append("D", null); 
        exit = new Command("Exit", Command.EXIT, 1);
        if (no == 4) {
          next = new Command("Finish", Command.EXIT, 2);
        } else {
          next = new Command("Next", Command.EXIT, 2);
        list.addCommand(exit);
        list.addCommand(next);
        list.setCommandListener(this);  
        display.setCurrent(list);
    }

    Ok, I haven't really worked much with files in J2ME and I haven't worked with MIDP 2.0 at all, but I'm fairly certain that there is no JDBC available in CLDC. If you're programming for a mobile phone then you can't use SQL. It's only available for CDC
    You're on the right track with the Connector; explore that further.
    But not every phone has a filesystem; keep that in mind. Some only expose an RMS for data storage to MIDlets.
    Message was edited by:
    nogoodatcoding

  • I need help for printing service in Java

    Hello :
    I need to print some file from java program .
    I did every thing , but when i run the program : it didn't return any printer as print service from the system, although I install 2 printers in my system.
    by the way : i use Windows XP

    I was in a rush this morning and forgot my crystal ball. Please post your code and remember to use the code tags.

  • Hello i need help for adobe creative cloud...when i launch application adobe  cc 2014  for photoshop or illustrator.....the apps launch and i can see the workspace and menu bar  for a while and  suddenly this application close automatic

    hello i need help for adobe creative cloud...when i launch application adobe  cc 2014  for photoshop or illustrator.....the apps launch and i can see the workspace and menu bar  for a while and  suddenly this application close automatic

    Sign in, activation, or connection errors | CS5.5 and later
    Mylenium

  • I have flash professional cc and I need air for desktop application with .exe or .air that should contain all swf's and captive air runtime in one Installer only . I don't want to install separate adobe air runtime .

    I need Air for desktop application either in .exe or in .air with embedded captive runtime just like .apk . I don't want to install adobe air separate . everything should come in installer
    I have adobe flash professional cc development tool , let me know whether I have to go with other development tool???
    your reply will  increase my confidential level
    please anyone can help me to solve this problem
    Thanks&regards
    Niranjan

    Adobe Flash Professional CC manual
    1) Create new project
    2) Configure your Project properties
    3) Embed runtime, so you users can use Adobe AIR without pre-installed Adobe AIR runtime
    4) After publishing you will receive %APP_NAME%.app folder that contain your project files

  • Need help for Format HD

    Hi I need Help for Formating HD so Wat Key need hold on start up for format HD I apprciated you Help

    Jesus:
    Formatting, Partitioning Erasing a Hard Disk Drive
    Warning! This procedure will destroy all data on your Hard Disk Drive. Be sure you have an up-to-date, tested backup of at least your Users folder and any third party applications you do not want to re-install before attempting this procedure.
    • With computer shut down insert install disk in optical drive.
    • Hit Power button and immediately after chime hold down the "C" key.
    • Select language
    • Go to the Utilities menu (Tiger) Installer menu (Panther & earlier) and launch Disk Utility.
    • Select your HDD (manufacturer ID) in left side bar.
    • Select Partition tab in main panel. (You are about to create a single partition volume.)
    • _Where available_ +Click on Options button+
    +• Select Apple Partition Map (PPC Macs) or GUID Partition Table (Intel Macs)+
    +• Click OK+
    • Select number of partitions in pull-down menu above Volume diagram.
    (Note 1: One partition is normally preferable for an internal HDD.)
    • Type in name in Name field (usually Macintosh HD)
    • Select Volume Format as Mac OS Extended (Journaled)
    • Click Partition button at bottom of panel.
    • Select Erase tab
    • Select the sub-volume (indented) under Manufacturer ID (usually Macintosh HD).
    • Check to be sure your Volume Name and Volume Format are correct.
    • Click Erase button
    • Quit Disk Utility.
    cornelius

  • Need help for cenvat reversal

    Hi Friends,
    Need help for cenvat reversal.
    Reversed MIRO by MR8M & MIGO by 102 movement but not able to post & cancel cenvat by J1IEX.
    In table J_1IEXCHDR status = "P" and J1I5 does not update for document of 102 movement because reversal document of MIGO, i.e. material document with 102 movement type does not have excise tab. MBSM-Cancelled Material Documents, does not show any of the material documents.
    Want to reverse the cenvat credit, please help.
    --Anil Bhamere

    Hi,
    If I select Cancellation in MIGO then there is only Material Document option.
    In MIGO Purchase Order option shows for Goods Receipt, Goods Issue and Subsequet Adj.
    In this case I have been selected Goods Receipt option followed by purchase order number by which original goods receipt MIGO was created, selected 102 movement type and from line item respective MIGO document. The reversal document created successfully where as original MIGO document does not show in cancelled document list. When post option selected from J1IEX and entered vendor excise number then message appeared as No Part I exists for availing credit in excise invoice xxxxx.
    If Cancel option selected from J1IEX and entered vendor excise number then message appeared as Excise invoice xxxx has already been posted for vendor xxxxx.
    Please help.
    Regards,
    Anil Bhamere

  • Needs steps for Printer setting for User-customized Paper Size

    Hii
    I need steps for Printer setting for User-customized Paper Size
    for my requirement i hav to design this for a paper which is 9cm length and width 23cm and printer is Laser printer
    Thanks
    Ravi

    Hi ,
    Kindly send me materials regarding printer configuration , I need to confiure a printer .Kindly help me.
    My ID  is rakeshhaari at gmail dot com
    Regards,
    Hari

  • I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    http://www.apple.com/support/itunes/contact/

  • Need help for my requirement...

    Need help for my requirement...
    Hello Experts,
    I have report where users can input the company, housebank, account ID and posting date.
    Now in one column of my report named 'Cash in Bank', I need to get all postings from cash
    accounts with GL code ending in '0'. Now, I know that I can get the amounts in BSIS/BSAS
    but how do I link it with the proper bank and account?
    For example:
                       Cash in Bank
    Bank A
      Account ID 1     1,000,000
      Account ID 2     25,000,000
    Hope you can help me guys. Thank you and take care!

    hi Viraylab,
    each house bank you can find in table T012, in T012K you'll find the bank accounts to the housebank, the G/L account will be in T012K-HKONT.
    hope this helps
    ec

  • Need help for flash builder

    i need help for flash builder 4 and papervison 3d. I need to create a slider with it ranges of value from 10 to 50 to adjust the camera values for the camera.fov and also need to create it for the yaw of the object from 0 to 360. I try to look for any slider event and classes in this program but cant find any, btw, i need to use the AS only project file.
    here is my codes:
    can you please tell me how i should modify the codes?
    package
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.events.Event;
        import org.papervision3d.materials.BitmapFileMaterial;
        import org.papervision3d.materials.BitmapMaterial;
        import org.papervision3d.objects.primitives.Sphere;
        import org.papervision3d.view.BasicView;
        [SWF (width="800", height="600", backgroundColor="0x000000",frameRate="30")]
        public class EarthBitmap extends BasicView
            private var sphere:Sphere;
            public function EarthBitmap()
                super(800 , 600);
                var earthmaterial:BitmapFileMaterial = new BitmapFileMaterial("../assets/Earth.jpg");
                sphere = new Sphere(earthmaterial,100,20,18);
                camera.fov = 25;
                scene.addChild(sphere);
                addEventListener(Event.ENTER_FRAME,rotateSphere);
            public function rotateSphere(evt:Event):void
                sphere.yaw(0.2);
                singleRender();

    Turn the click handler into a full on separate function. Then store all the views in an array and use Math.rand() to randomly choose one.
    Something like this:
    <fx:Script>
         <![CDATA[
              var questionsArray:Array = {question2,question3,question5,questionRed,questionGeography};
              function buttonClickHandler(event:MouseEvent){
                   var randomProblem:int = Math.floor(Math.random()*(questionsArray.length));     //generates a random integer between 0 and the total number of questions in the array (arrays are 0-based)
                   navigator.pushView(questionsArray[randomProblem]);
         ]]>
    </fx:Script>
    <s:Button id="randomProblemButton" label="Next Problem" click="buttonClickHandler(event)" />
    Haven't tested that, but something along that line should work

  • Need help for importing oracle 10G dump into 9i database

    hi, Someone help me to import oracle 10G dump into 9i database. I'm studying oracle . Im using oracle 10G developer suite(downloaded from oracle) and oracle 9i database. I saw some threads tat we can't import the higher version dumps into lower version database. But i'm badly need help for importing the dump...
    or
    someone please tell me the site to download oracle 9i Developer suite as i can't find it in oracle site...

    I didnt testet it to import a dump out of a 10g instance into a 9i instance if this export has been done using a 10g environment.
    But it is possible to perform an export with a 9i environment against a 10g instance.
    I am just testing this with a 9.2.0.8 environment against a 10.2.0.4.0 instance and is working so far.
    The system raises an EXP-00008 / ORA-37002 error after exporting the data segments (exporting post-schema procedural objects and actions).
    I am not sure if it is possible to perform an import to a 9i instance with this dump but maybe worth to give it a try.
    It should potentially be possible to export at least 9i compatible objects/segments with this approach.
    However, I have my doubts if this stunt is supported by oracle ...
    Message was edited by:
    user434854

  • Need Help for Nokia 6500 slide

    Hi all I'm A new Guy here ,
    But I do really need help for hard reset my phone
    I already try *#7073# But It doesn't work ,
    If Anybody know to make a hard reset please help

    rwss wrote:
    I'v got te same problem with my 6500 Slide, is there a button combination that we have to press
    to hard reset the 6500 Slide?!
    How does the 6500 slide hard reset?
    That's simple.
    All you have to do is:
    From MENU goto SETTINGS, When there scroll down and select 'Restore Factory Setting'.
    There are two options in there:
    "Restore Settings only"
    and
    "Restore all"
    Select "Restore All"
    When done the phone will delete every thing on the Phone memory(C:\)(contacts,picture,messages etc)
    and also restore phone to its original settings and will restart.
    This proceedure is mostly common on S40 phone.
    Hope this explain and solve the problem.

  • Need help for publishing web intelligence document (universe) into InfoView

    Post Author: mirage
    CA Forum: Publishing
    Hello all,
    I need help for publishing web intelligence document (universe) into InfoView.
    can't find this information in Business Objects Designer's Guide and in Business Objects Administrator Guide.
    Can somebody give short instructions how can I do it?
    Regards, Slava

    If the change between the 2 types of data has to happen dynamically during run time them
    1. Use 2 dataproviders
         a. Current
         b. Historic
    2. Merge the 2 dimensions
    3. Use Webi variable to switch between the measure of the current and historic universe
    Ex  if [year] < 2010 then historic.[expense] else current.[expense]
    Hope this helps,
    Divya

Maybe you are looking for

  • Missing "Compact List View" in View menu in v7.7

    Observed behavior: my contacts are in compact view I want to switch them to regular view I don't see the option in the View menu (see screenshot) Attachments: Screenshot 2015-05-20 11.20.21.png ‏60 KB

  • -6502 ORA-06502: PL/SQL: numeric or value error when using 'Create CAPI Definition'

    I get an error when I try to create a CAPI definition with Headstart untilities (6i). I use HSU_CAPI revision 6.5.2.0 The detailed information says the following: Message BLAPI.OPEN_ACTIVITY Start HSU_CAPI.run Number of Tables to create CAPI for 1 In

  • Airport express problem

    I was successfully running two separate airport expresses to make some speakers wireless in different areas of my house. This was with my old linksys router, and everything was great. My router died though, so i purchased an airport extreme to use as

  • Make notification actionable feature in Human Task

    Hi All, While creating a Human Task, I have selected the option "Make notification actionable". So, in the notification email i get all the custom outcome links. They appear in a default format. I wanted to know is there any way we could control thes

  • Tablespace Size

    hi, I am using Oracle 8i. From DBA studio i see that the space assigned to data files is 98.5% full. will it affect performance ?? Ther is very few much space avaiable in the drive. Data file size is around 12 GB auto extend is 50% and free space is