Microsoft KB Archive/261123

From BetaArchive Wiki
Knowledge Base


Article ID: 261123

Article Last Modified on 6/14/2006



APPLIES TO

  • Microsoft Java Virtual Machine



This article was previously published under Q261123

SYMPTOMS

When you are accessing the same applet that launches both a modal and modeless dialog from two different Web servers, the following security exception results

com.ms.security.SecurityExceptionEx[Test.actionPerformed]: cannot connect to "<host name 2>"

when you try to display the modal dialog box from both servers.

NOTE: Launching the modeless dialog box doesn't throw an exception.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug has been verified to occur in the 3100 series of the Microsoft virtual machine.

This problem was corrected in Windows 2000 Service Pack 1.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create the following file as Test.java.

    import  java.applet.Applet;
    import  java.awt.*;
    import  java.awt.event.*;
    import  java.io.*;
    import  java.net.*;
    
    public class Test extends Applet implements ActionListener
    {
        Button btn1 = new Button ("Modal Dialog");
        Button btn2 = new Button ("Modeless Dialog");
    
        public void init ()
        {
            btn1.addActionListener (this);
            btn2.addActionListener (this);
            add (btn1);
            add (btn2);
        }
    
        public void actionPerformed (ActionEvent ev)
        {
            try
            {
                Object source = ev.getSource ();
                SampleDialog dlg;
    
                System.out.println (((Button) source).getLabel ());
                if (source == btn1)
                {
                    dlg = new SampleDialog ((Frame) getParent (), true);
                    dlg.setVisible (true);
                }
                else if (source == btn2)
                {
                    dlg = new SampleDialog ((Frame) getParent (), false);
                    dlg.setVisible (true);
                }
            }
            catch (Exception ex)
            {
                System.out.println (ex);
                ex.printStackTrace ();
            }
        }
    }
    
    class SampleDialog extends Dialog implements ActionListener
    {
        Button btnClose = new Button ("Close");
    
        SampleDialog (Frame f, boolean mode)
        {
            super (f, "Sample Dialog", mode);
            btnClose.addActionListener (this);
            setLayout (new BorderLayout ());
            add (btnClose, BorderLayout.CENTER);
            pack ();
        }
    
        public void actionPerformed (ActionEvent ev)
        {
            if (ev.getSource () == btnClose)
                setVisible (false);
        }
    }
                        
  2. Compile Test.java as follows:

       java Test.java
                        
  3. Reference the above Java class in an HTML file as follows:

    <APPLET CODE="Test" WIDTH="500" HEIGHT="400">
    </APPLET>
                        
  4. Place both the HTML and Java class files on a Web server.
  5. Create a similar Java class and HTML file and place it on another Web server.
  6. Launch the first HTML page, and then click the Modal Dialog button.
  7. Leave the dialog box open and create a new window in Internet Explorer. Launch the second HTML page and click the Modeless Dialog button.

    The SecurityExceptionEx is generated. To see the details on the exception, you can view the Java Console in Internet Explorer.


REFERENCES

For additional information about the latest service pack for Windows 2000, click the article number below to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack


For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:


Additional query words: SecurityExceptionEx Modal

Keywords: kbbug kbfix kbjavavm33xxfix kbwin2000sp1fix KB261123