Microsoft KB Archive/261123

= FIX: SecurityExceptionEx Is Generated When You Access an Applet from Two Different Web Servers =

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 &quot; &quot;

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.



Steps to Reproduce Behavior
  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 (&quot;Modal Dialog&quot;); Button btn2 = new Button (&quot;Modeless Dialog&quot;);

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 (&quot;Close&quot;);

SampleDialog (Frame f, boolean mode) {       super (f, &quot;Sample Dialog&quot;, mode); btnClose.addActionListener (this); setLayout (new BorderLayout ); add (btnClose, BorderLayout.CENTER); pack ; }

public void actionPerformed (ActionEvent ev) {       if (ev.getSource  == btnClose) setVisible (false); } }                     Compile Test.java as follows:   java Test.java   Reference the above Java class in an HTML file as follows:    Place both the HTML and Java class files on a Web server. Create a similar Java class and HTML file and place it on another Web server.</li> Launch the first HTML page, and then click the Modal Dialog button.</li> 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.</li></ol>

<div class="references_section">