Opening a socket from an applet

I tried to open a socket from an applet to a server on a remote computer and I've got a refusal message.
When I try it on a server in the local machine, it works.
What could be the problem ?
P.S. : when I open the socket from an application in the Java environment, to the same remote server it works ok.

this is part of the security system built into java and Applets
unless you sign an Applet it cannot do many "dangerous" things, like..
access the loacl file system
connect to any server except the server that it came from

Similar Messages

  • Opening a browser from an applet

    I got a problem, I want to open a browser from my applet, but I just found one way:
    getAppletContext().showDocument(new URL(
    "http://www.java.sun.com"), "_blank");
    but the problem is: with this, the default browser with defaul settings is opened, and that's what I don't want...
    how can I open the browser with some settings (for example size, or no-url-bar, etc)
    thx for help

    hi,
    try this code:
    public void showDocument(java.net.URL url, String targetWindow)
    when targetWindow can be:
    "_blank" Display the document in a new, nameless window.
    "windowName" Display the document in a window named windowName. This window is created if necessary.
    "_self" Display the document in the window and frame that contain the applet.
    "_parent" Display the document in the applet's window but in the parent frame of the applet's frame. If the applet frame has no parent frame, this acts the same as "_self".
    "_top" Display the document in the applet's window but in the top-level frame. If the applet's frame is the top-level frame, this acts the same as "_self".

  • [NEWBIE] How to open a frame from an Applet?

    Hi, I'm trying to open a JFrame from an Applet. Basically, I would like that, once the user selects an option from a JMenu, a Frame would be shown with a text box where user could type some content.
    I built both the Applet and the Frame, and singularly they work. When I execute the main method from the JFrame, the window appears, but when I execute something like the following from the applet:
    MyFrame mf = new MyFrame();
    mf.setVisible(true);nothing is shown. I'm sure that I don't know something, but I just started with applets.
    Thanks for any help,
    Marco

    If MyFrame is a subclass of JFrame, then it should not
    make any difference.
    What do you need the JFrame for? Can this be done
    using another "screen" by using a CardLayout?From a menu, when the user selects 'Start game' I need a text box coming out so that the user can insert a word. This word should then evaluate an instance member of the Applet.
    Marco

  • Open a socket from a LAN (with a proxy connect to internet) to outside

    Hi everybody
    I have a chat program that opens a socket through which I sent voice data. Every one that wants to receive voice must open a sockect to the computer sending the voice. (It means that if you want to send data you must open a socket to another computer and if you want to receive you S.O. must open a socket to you). It works ok with all computers inside the LAN. Now I'd like to stablish a connection to a computer which is outside this LAN (my computer at home). From here, using some ports which are not closed by the firewall at the proxy I can connect my computer at home.
    My questions are:
    Can I use the same socket to send and receive data? Or they are only 'one-way' direction, so I need another socket from home to here?
    How can I open the socket from home to here? Is there a way to send my computer at home the whole addres at work? I mean sent my computer at home my 'mac address' or something so the proxy knows where to send the packages received from outside?
    Thanks,
    Dani.
    I WILL GIVE YOU 10 DUKES IF YOUR SOLUTION WORKS.

    How can I open the socket from home to here? Isthere
    a way to send my computer at home the whole addresat
    work? I mean sent my computer at home my 'mac
    address' or something so the proxy knows where to
    send the packages received from outside?This can't be done (as far as I know).
    /KajOr, well. You might be able to configure the proxy to do port forwarding, but I guess that you don't want to do that?

  • Opening a frame from an applet

    Hi,
    I want to open a frame in my applet. If I'm using swing, JApplet opening a JFrame, is it possible to keep the frame open if the user browses away from the page that holds the applet?
    Are there any tricks? I've tried opening it in a new Thread, but it still goes away when the the browser's page changes.
    Could I call getParent() from the applet until I get an instance of Frame (which would be the browser) and set my JFrames' parent? Or does that only work with the old Netscape and old AWT Frames?
    I basically want to know if I can keep my JFrame open until the browser is closed. Any ideas or suggestions would be greatly appreciated.
    thank you very much

    Do you want to open a jsp application in a frame when you click on the applet?If so, there is a programme in http://www.globalleafs.com -Java-Java Applets 's download section. Check it out.

  • Open client socket from within a Web Service

    Hello,
    I need to open a client TCP/IP socket from within a Web Service-type WebLogic
    Workshop app. When I try to read from the socket, the socket read operation hangs.
    When I use the same code in a J2SE Java app on the same machine using Eclipse
    everything works fine. It also works fine from within WebLogic, if I use a "URL"
    object instead of a "Socket" object. (However, I cannot use this type of connection.)
    Can anyone tell me how to work with raw TCP/IP sockets in this situation?

    Hi Udi,
    I have tested my code from within a Servlet and it works fine.
    The Servlet and the Web Service both call the same simple JAVA class. This class wants to access a DB, and therefor, I am using the Data Source.
    When the Servlet calls the class, everything works fine. But when I use the Web Service to call this class, I get the Exception "No attributes are implemented".
    I hope this information helps you understanding my problem?
    Thank you very much for your help.
    Kind regards,
         Nadine

  • Open web pages from an applet

    I'm developing an applet that has to open some web pages.
    The only way I know is to use the method showDocument that
    needs and URL. So, how to pass parameters to the web page?
    I don't want to put them in the URL: everyone can see
    "secret data"!
    Help me, please.

    Take a look at this example that uses a JEditor pane to hold the HTML page.
    //Create a new JEditor Pane
    jep = new JEditorPane( );
    //Ensure the pane is not editable
    jep.setEditable(false);  
    //Use this to get local HTML file
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");
    //add the html page to the JEditorPane
    jep.setPage(fileURL);Ok the core line of code here is this.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");The standard method for accessing a html file via a URL is thus. As you can see its very similar.
    URL fileURL = new URL("http://www.comp.glam.ac.uk/pages/staff/asscott/progranimate/docs/Manual/Manual.htm");this.getClass().getResourse() will return the file location of the class you are working with.
    By doing the following you can access manual.html in a folder called Manual that sits in the same file location as the class file you are using.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");I hope this helps.
    Andrew.

  • Open a JFrame from an applet

    I have an applet in which I have a JButton.
    When you click the button, I want a new window to open with a JFrame. Is that possile?
    I've written as follow but nothing happens when I click the button.
    1. In the applet, I've written:
    public class MyApplet extends Applet {
    if (e.getActionCommand() == myButton) {
    frame.getContentPane().add(new Blabla(), BorderLayout.CENTER);
    2. In the frame, I've written:
    public class Blabla extends JFrame {

    Thanks.
    Now a new window is opened when I click the button, but it's empty....
    In the frame I have a container, is that a problem? I don't know where to put "your":
    "getContentPane().setLayout(new BorderLayout());"
    I've written:
    public class Blabla extends JFrame {
    boolean inAnApplet = true;
    private boolean laidOut = false;
    private JButton b1, b2, b3;
    private JLabel fnamn;
    public Blabla() {
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    b1 = new JButton("some text");
    contentPane.add(b1);

  • Opening a jsp from an applet in a frame?

    this is the code i'm using to open a new jsp and send some stuff in the header. it works fine but it does not support the frameset i am using... any ideas how i can open this page in the frame?
    thanks
    URL url = getCodeBase();
    try{
    getAppletContext().showDocument (new URL (url+"AcceptHousePos.jsphouse="+myHouse.getString()));
    catch(MalformedURLException e) {
    showStatus("URL not found");

    Do you want to open a jsp application in a frame when you click on the applet?If so, there is a programme in http://www.globalleafs.com -Java-Java Applets 's download section. Check it out.

  • How do I open a url from an applet?

    is it done the same way with HTTPUrlConnection as with an application or is it done in a different way? I'm getting a "ClassCastException"

    Now I'm trying to call a CGI script and past things in through the post method... I still get a ClassCastException. This exact same code worked in the applet, once again. here is the code I am using:
                   URL url = new URL ("http://address.pl");
                   HttpURLConnection cxn = (HttpURLConnection) url.openConnection();
                   cxn.setRequestMethod("POST");;
                   cxn.setUseCaches(false);
                   cxn.setDoOutput(true);
                   cxn.setDoInput(true);
                   ByteArrayOutputStream bytes = new ByteArrayOutputStream(400);
                   PrintWriter writer = new PrintWriter (bytes,true);
                   writer.print("hello=world&food=good");
                   writer.flush();
                   cxn.setRequestProperty("Content-Length",String.valueOf(bytes.size()));
                   cxn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
                   bytes.writeTo(cxn.getOutputStream());

  • Opening frames from an applet

    Me and a friend are making an applet, and would like it to open a new frame at some point.
    It works perfectly* on his WIN 2k IE 5.0 but somehow it does not on my WIN 2k IE 6.0
    Is it no longer legal to open new windows from an applet?
    Thanks.
    *Except for the warning. Btw, is that warning removable?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    If the window doesnt show up, you might have an exception thrown somewhere. I assume you are using a Java Plug-In since you are using IE6.0. You can bring up the java console, if you open the Java Plug-In icon in the Control Panel and enable "Show Java Console". Restart your browser and try again and see if you are getting a stacktrace in the java console.You can also see what version of java you are using in the control panel, or change it in the Java Plug-In options (Advanced tab) if you have more than one installation installed.

  • Applet not opening a socket on its own host. Please help.

    I have also posted this in JSC2 forum.
    My applet is not able to open a socket on its own host.
    The applet is being served by a JSP (developed using Sun Creator2) from my laptop behind a DHCP broadband router at (say) 125.238.104.132 at my residence. I have a URL �samsub.no-ip.biz� that redirects port 80 calls to 29080 where my application runs. All required router rules/mapping are done and the JSPs run perfectly fine. In one of the pages, I have inserted an applet inside an escape disabled statictext field as follows:
    <applet code="AppClient.class" width=540 height=440></applet>
    The applet code and the test server code are shown below for your analysis. Note that, when run on the same machine (at home), the applet works fine. The commented lines will show other failed test. The error reported at the java console was: null pointer at line 56
    Could someone help me please. Thanx. MarySam
    The applet code
    1     import java.util.*;          
    2     import java.awt.*;          
    3     import java.applet.*;          
    4     import java.text.*;          
    5     import javax.swing.*;          
    6     import com.sun.java.swing.plaf.windows.*;          
    7     import java.awt.event.*;          
    8     import java.net.*;          
    9               
    10     public class AppClient extends Applet {          
    11     JInternalFrame jif;          
    12     JTextArea jta1, jta2;          
    13     Socket kkSocket = null;          
    14               
    15     public void init() {          
    16          try {     
    17               LookAndFeel lf = new WindowsLookAndFeel();
    18               UIManager.setLookAndFeel(lf);
    19          kkSocket = new Socket("125.238.104.132", 4444);
              //kkSocket = new Socket("samsub.no-ip.biz", 4444);
              //kkSocket = new Socket("125.238.104.132:29080", 4444);
              //kkSocket = new Socket("samsub.no-ip.biz:29080", 4444);
    20          }      catch(Exception e) {}
    21               
    22          setLayout(null);      
    23          setBackground(Color.black);     
    24          jif = new JInternalFrame();     
    25          jif.setLocation(20,20);     
    26          jif.setSize(500,400);     
    27          Container con1 = jif.getContentPane();     
    28          con1.setLayout(null);     
    29               
    30          jta1 = new JTextArea();      
    31          JScrollPane jcp1 = new JScrollPane(jta1);     
    32          jcp1.setBounds(10,10,410,100);     
    33          con1.add(jcp1);     
    34               
    35          jta2 = new JTextArea();     
    36          JScrollPane jcp2 = new JScrollPane(jta2);     
    37          jcp2.setBounds(10,115,470,245);     
    38          con1.add(jcp2);      
    39               
    40          JButton jb = new JButton("Go");     
    41          jb.setBounds(425,10,60,30);     
    42          jb.addActionListener(this);     
    43          con1.add(jb);      
    44               
    45          JLabel jlb = new JLabel();     
    46          jlb.setOpaque(true);     
    47          jlb.setBackground(Color.gray);     
    48          jlb.setForeground(Color.white);      
    49          jlb.setBounds(425,50,60,30);     
    50          con1.add(jlb);      
    51               
    52               
    53          jif.setVisible(true);     
    54          add(jif);      
    55          //jta2.setText(getCodeBase().toString());     
    56          jta2.setText(kkSocket.getInetAddress().toString());     
    57               
    58     }          
    59               
    60     public void start() {}          
    61               
    62     public void stop() {}          
    63               
    64               
    65     }          
    66               
    67               
    The test server Code
    1     import java.net.*;                         
    2     import java.io.*;                         
    3                              
    4     public class MyServer {                         
    5     public static void main(String[] args) throws IOException {               
    6                              
    7     ServerSocket serverSocket = null;                    
    8     try {                         
    9     serverSocket = new ServerSocket(4444);                    
    10     } catch (IOException e) {                         
    11     System.err.println("Could not listen on port: 4444.");          
    12     System.exit(1);                         
    13     }                         
    14                              
    15     Socket clientSocket = null;                         
    16     try {                         
    17     clientSocket = serverSocket.accept();                    
    18     System.out.println(clientSocket.getInetAddress().toString());          
    19     } catch (IOException e) {                         
    20     System.err.println("Accept failed.");                    
    21     System.exit(1);                         
    22     }                         
    23                              
    24     clientSocket.close();                         
    25     serverSocket.close();                         
    26     }                         
    27     }                         
    28                              
    29

    Hi Guys,
    I'm not actually from Mozilla Firefox, but I've had this problem before, and I've solved it with the help from another website.
    What you need to do is download a programme called "tdsskiller" from here:
    http://www.geekpolice.net/t23369-computer-infected
    scroll down the page and you should see a link. (I know the article itself seems irrelevant to your problem, but trust me, the programme they recommend works on this virus too.) It's only 1.3MB or so, so it doesn't take up huge amounts of space either! :)
    I can safely say that it is COMPLETELY safe to download this from geekpolice.net, as this website is a free website which helps people with viruses on their computer. If you ever have another problem with anything to do with computers, go and have a look on geekpolice.net, they should have something that might help you.
    Before anyone wonders why I am singing its praises so much, no I am not advertising them for any personal gain, but they have helped me get rid of some pretty nasty viruses on my computer before, so I am very grateful to them :)
    SO, anyway, after you've downloaded the tdsskiller, you should run it, and it may find some infected files, in which case let it repair them. After rebooting your computer, the annoying opening tab thing should be gone!
    I hope this works for anyone who's stuck :) If it doesn't, I'm really sorry, but it has definately worked for me!
    Good luck!
    Yashmeee :)

  • Opening and closing a frame from an applet security problem

    can I open a frame or a window from an applet and close the frame by using
    System.exit(0) for the frame or will it throw a security problem.

    I am using system.exit(0) to exit the JVM.
    dispose()
    Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.
    If this frame have to be close and open again don't use dispose.
    there is no check whether a frame is active? what you can do is set the the new frame to null (frame = null) and also when you dispose it, this will let you know if the frame is active or not.
    Noah

  • Print HTML doument without open it from an applet

    I need to know how I can print an HTML document from an applet developed with Jbuilder 4. I'm not a very expert developer and I need a detailed information about this problem. Important is that the HTML document is printed without open it.
    I use: win 2000 pro
    J2RE 1.4.0
    thanks in advance for your help
    Mauro Losa

    Thanks for your help but my problem is that i want print the document without display it.
    I think to have find a solution using Java Print Service API (JDK 1.4) but when i run the example the system display this error refered to this instruction
    "PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);":
    java.lang.UnsatisfiedLinkError: getDefaultPrinterName
    at sun.print.Win32PrintServiceLookup.getDefaultPrinterName(Native Method)
    at sun.print.Win32PrintServiceLookup.getDefaultPrintService(Unknown Source)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Unknown Source)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Unknown Source)
    at javax.print.PrintServiceLookup.getServices(Unknown Source)
    at javax.print.PrintServiceLookup.lookupPrintServices(Unknown Source)
    at untitled4.applet1.main(Applet1.java:32)

  • 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.

Maybe you are looking for

  • Error message -L3199-Total for assigned quantities exceeds quantity to be removed

    Hi, We are facing problem in picking at last HU in WM while creating transfer order for delivery document in PRD. We reproduced same issue in QXS. Sales order was created with 40 Drums and also delivery with 40 Drums. Conversion factor mantained in m

  • Need to clear openitems for Bank Reconciliation without useing Algorithms

    Dear All, As per configuration of Manual Bank Reconciliation, for clearing cheque deposit & cheque issue we are useing Algorithms 15 & 13 respectively. while uploading Bank statement we used to give SIX digit cheque number as a reference to clear the

  • How can I fix a song in itunes?

    Hi, I purchased a song and trying to turn it into a ringtone for my iphone 5 (following instructions on the support forum), the original has got messed up- I have one copy of the song that is now three seconds, and one copy that works for two seconds

  • Import XML to InDesign

    New to XML in InDesign, I have a few question, so if you only can answer one or two, please do so. 1. Is there a way to get InDesign to display in the structure the content of the tag, rather than the tag name over and over again? 2. Can you make a s

  • Why did some applications have to rebuild their database after a Time Machine rollback?

    Recently my system (10.8) got totally borked, so I booted into recovery mode and rewrote the entire disk from a two day old Time Machine backup. When I started back up, I found that: Spotlight needed to reindex the entire disk. Dropbox didn't recogni