Printing HTML PAGE in a Applet

I am tryng to print a HTML Page in a Applet .
When Using Eclipse Environment everythig goes fine.
Now I am trying to use the appletviewer to run the same
source, but it appears the following:
http://10.15.1.26/
Conecting to http://10.15.1.26/
Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: java.security.AccessControlException: access denied (java.net.SocketPermission 10.15.1.26:80 connect,resolve)
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
     at java.net.HttpURLConnection.getResponseCode(Unknown Source)
     at javax.swing.JEditorPane.getStream(Unknown Source)
     at javax.swing.JEditorPane.setPage(Unknown Source)
     at javax.swing.JEditorPane.setPage(Unknown Source)
     at javax.swing.JEditorPane.<init>(Unknown Source)
     at AppletPrintHTML$EditorPaneHTMLViewer.loadStartingPage(AppletPrintHTML.java:90)
     at AppletPrintHTML$EditorPaneHTMLViewer.<init>(AppletPrintHTML.java:103)
     at AppletPrintHTML$5.actionPerformed(AppletPrintHTML.java:364)
     at java.awt.Button.processActionEvent(Unknown Source)
     at java.awt.Button.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 10.15.1.26:80 connect,resolve)
     at java.security.AccessControlContext.checkPermission(Unknown Source)
     at java.security.AccessController.checkPermission(Unknown Source)
     at java.lang.SecurityManager.checkPermission(Unknown Source)
     at java.lang.SecurityManager.checkConnect(Unknown Source)
     at sun.net.www.http.HttpClient.openServer(Unknown Source)
     at sun.net.www.http.HttpClient.<init>(Unknown Source)
     at sun.net.www.http.HttpClient.New(Unknown Source)
     at sun.net.www.http.HttpClient.New(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
Why I am not allowed to connect to the site without Eclipse? Any Idea?
Angel Portal

This code
          * Load a HTML Page
          private void loadStartingPage() {
          try {
               System.out.println("Conectando a "+ path);
               mainPane = new JEditorPane(path);
               } catch (IOException e) {
                    System.err.println("N�o Pode Conectar");
                    System.exit(1);
Open a html page ( path ) on JEditorPane!
In Eclipse worked just fine!
But if I try to do that on a Browser or appletviewer the error a told you shows up.
I am reading about the The Permission Classes.Someone have heard of it?

Similar Messages

  • Print Html page Using Java

    I need to print Html Page into my printer, how can I do this. Any help will be appreciated.
    Wil

    File > Print.
    See: http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/printing2d.fm.html
    And:
    http://java.sun.com/j2se/1.4.2/docs/guide/jps/index.html
    And google "Java JPS"

  • Replace HTML page with an applet

    Hello to everybody!
    I created a servlet who can manage file upload from an HTML page.
    Now I want to replace that HTML page with an applet.
    I know that I need to use multipart/form-data , but I have no experience with applet.
    HTML page code is:
    <html>
    <head><title>Upload</title></head>
    <body>
    <FORM ACTION="http://localhost:8080/examples/servlets/servlet/UploadTest" ENCTYPE="multipart/form-data" METHOD=POST>
    What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>
    Which file do you want to upload? <INPUT TYPE=FILE NAME=file> <BR>
    <INPUT TYPE=SUBMIT>
    </FORM>
    </body>
    </html>
    Any help for "translating" this html page into an applet?
    Applet will send, like html page, a string and a file.
    Thanks in advance, Liuk

    If you use something like Apache Http Client you dont have to do any low level implementations.
    Also if you are the one who is writing both servlet and applet you dot have to stick to standerd formats. you can develop your own format and write both servlet and applet to handle it. that kind of thing can be done easily even with URLConnection. But if you plan to send large files then URLConnection may not be the right option becouse I have seen many complaining that URLConnection gives OutOfMemoryErrors when uploading large amounts of data.

  • Printing HTML PAGE

    Java has some Class to handle HTML Pages.
    I want to build a Button that is able to print the
    actual page of the Browser.
    I know about ClipBoard Class, SomeOne has
    some Idea how to do this?
    The idea is to create an applet that creates a button
    to print the actual HTML page.
    Some Idea how to do this, or where I can get this
    information?
    Angel -Portal

    Hello, I got your advise and I could write a small program
    to open a URL ,put it in a JEditorPane like you sad.
    public class EditorPaneHTMLViewer extends JEditorPane implements Printable {
    Inside the code I create a menu to change to portrait to landscape.
    But now I need somehow to print the HTML Page that I took from
    internet.
    I believe that I need to load the content of the JEditorPane to a graphics
    and then set to a Format of a Page and Print, but I do not know how yet.
    Some Hint.
    That true that I could do in a easiest way in JavaScript. But it is going to
    be possible to do landscape and portrait?
    Angel Portal: [email protected]

  • Open a html page from an applet

    Hi,
    I would like to open, from an applet, an HTML page in a new window with a specific width an eight.
    Who can help me ?

    Here is an example of applet to javascript with liveconnect:
    http://www.narhari.com/java/applet2javascript/
    You can use the send(String) method from the sample applet to send something like:
    window.open('xyz.html','myPopup','width=200,height=200');in order to open a window with specific dimensions
    of course you can also build HTML in your applet and use send() + some javascript to render it.

  • How to call and run HTML pages from an Applet?

    I want to run another HTML page when pressed a button in an Applet,how can i do it?

    Are you looking for this?
    applet.getAppletContext().showDocument("http://cullenwines.com.au", "_top");

  • Unable to print HTML pages

    After a good bit of reading, I found that printing HTML directly to the printer doesn't work for many printers. I don't want to print the code. I want the actual HTML page. I have some code here that reads the HTML file into a JEditorPane and then is rendered into a graphic for printing.
    My code compiles fine, I'm not getting any errors, but what I'm also not getting is any pages printing.
    Here is the source of my class:
    * PrintReport.java
    * @author tristan
    * Created on September 27, 2007, 4:06 PM
    package fedex;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import java.io.*;
    import javax.print.Doc;
    import javax.print.DocFlavor;
    import javax.print.DocPrintJob;
    import javax.print.PrintException;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.ServiceUI;
    import javax.print.SimpleDoc;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.swing.JEditorPane;
    import javax.swing.RepaintManager;
    public class PrintReport
        private FileInputStream fileIS;
        private Doc doc;
        private DocAttributeSet das = new HashDocAttributeSet ();
        PrintService defaultService;
        /** Creates a new instance of PrintReport */
        public PrintReport ()
        public void printHTMLFile (String file) throws FileNotFoundException, IOException
            PrintableEditorPane jEditorPane = new PrintableEditorPane ();
            jEditorPane.setContentType ("text/html");
            jEditorPane.read (new BufferedInputStream (new FileInputStream (file)), "");
            System.out.println (jEditorPane.getText ());
            PrinterJob job = PrinterJob.getPrinterJob ();
            job.setPrintable (jEditorPane);
            if (job.printDialog ())
                try
                    job.print ();
                catch (Exception ex)
                    System.out.println (ex);
        public class PrintableEditorPane extends JEditorPane implements Printable, Serializable
            public int print (Graphics g, PageFormat pf, int pageIndex) throws PrinterException
                Graphics2D g2 = (Graphics2D)g;
                g2.setColor (Color.black);
                RepaintManager.currentManager (this).setDoubleBufferingEnabled (false);
                Dimension d = this.getSize ();
                double panelWidth = d.width;
                double panelHeight = d.height;
                double pageWidth = pf.getImageableWidth ();
                double pageHeight = pf.getImageableHeight ();
                double scale = pageWidth / panelWidth;
                int totalNumPages = (int)Math.ceil (scale * panelHeight / pageHeight);
                System.out.println ("Total pages to print are " + totalNumPages);
                if (pageIndex >= totalNumPages) return Printable.NO_SUCH_PAGE;
                g2.translate (pf.getImageableX (), pf.getImageableY ());
                g2.translate (0f, -pageIndex * pageHeight);
                g2.scale (scale, scale);
                this.paint (g2);
                return Printable.PAGE_EXISTS;
    }I tried using a complex HTML file as well as a basic one, but everytime Total pages to print are 0 is printed back to the console. I can't figure out why it's unable to create any pages to print.

    DrClap wrote:
    I think you will find thatDimension d = this.getSize ();produces (0, 0) until you actually display your component somewhere. I believe it's possible to "display" it in such a way that it doesn't appear on the user's screen, but I don't know how.
    There's a Swing forum here where you get answers from people who are good at Swing. Posting here attracts answers from people like me who are mediocre at it.I think that calling validate() on a Container will lay it out and size it's components, even if it hasn't been made visible, but don't take my word for it.

  • How to display an image on the HTML page by using applet

    Dear friends,
    I am now writing an java applet, I want to display an image on the HTML page, and tried the following commands:
    {color:#ff00ff}{color:#000000}Image map; //put in the class definition
    map=getImage(getCodeBase(),"hhh.gif"); //put in the function of init()
    g.drawImage(map,0,300,this); //put in the function of paint(){color}
    {color}
    However, when I run it, the image wasn't displayed at all.
    I hope who guys ever come across this problem could help me to solve it. Thank you in advance!
    Hawaii

    Hi,
    I am no expert on Images
    but
    from personal exp.
    are you sure that map actually contains the image?
    try using
    ImageIcon ii = ImageIcon(String name);
    map = ii.getImage();I saw a tutorial on images i think on sun
    where they use ImageIcon to load the image

  • Problem Printing html page with JEditorPane...

    Hello All,
    I Have a problem in printin html file with JEditorPane...
    My Html file contains a Table on it..
    Problem is that JEditorPane displays the html file correctly but
    it prints the file without print that Table..
    So pls help me...
    Thanx in advance,..
    Amit
    [email protected]

    I think you would know how to retrieve content of an HTML page using the URL object. Just in case.
    My apology if this short note doesn't help you at all.

  • Problem in Printing HTML page

    While I am trying to print a HTML page using window.print(), the bgcolor of the table is not printing.

    Did you consider inquiring about this at a Javascript or HTML forum?

  • Viewing html page of an applet

    I am trying to write an applet.
    When I viewed the html page for the first time,
    it worked fine.
    But now it doesnt work properly.
    All the contents are not shown.
    I recompiled my code but the mistake remains.
    Please help

    Probably need to refresh the web browser cache; usually the browser "Refresh" function will do that; or close ALL browser windows and then try it again.

  • How to call html page from an applet

    I want to call a html page after the user presses a OK button in the applet. please help me in this.

    In you actionPerformed put:
    AppletContext appContext=getAppletContext();
    URL myURL= new URL("http://www.javasoft.com");
    String target="_self";
    appContext.showDocument(myURL,target);P.S. If you want to pen the URL in a new Browser window
    use
    target="_blank";

  • Safari prints HTML page as blank

    When I load an HTML page in Safari and print it, it's totally blank. Doesn't happen in Firefox with the same HTML files.

    Hi John,
    I don't see anything in the console that would be relevant. I'm happy to send you a log if you'd like to see it. (Lots of crap from TextExpander )
    Yes, the thumbnail is blank.
    I should mention I've already tried moving my printer plists to the trash.
    Thanks

  • Problems printing html page created from servlet

    Hi
    How do I go about to print a html page that spans outside the visible window (to the left). All I get when I print is the visible page.
    Is it at all possible?
    Would appreciate an answer.
    Thanks
    David Mossberg

    No, not impossible to do.
    You need to provide a printer friendly version of the content so that it spans correctly.
    Again, this is not a Java problem this is an Application problem.
    How you format the data is down to you.

  • Printing html pages from JSF-JSC created pages

    Hi all,
    I have a serious problem with my web apps created with JSC using the JSF components. I designed a page full of tables, developed in vertical for a total of about three or four pages scrolling down.
    When I try to print the generated page from the browser (Firefox, Safari, Explorer) I always get just the first 'page', the entire webpage generated by my application is not saw as a long page, but just 'cutted' out.
    It seems like all JSF components have some problems being like layers or so...any hint? How can I print my html page generated by my web app?
    G

    Perhaps viewing the source of the generated html page will give you a clue to what's wrong..

Maybe you are looking for