怎么实现同一个jsp页面中嵌入的两个applet之间的通信??急啊,请大家不宁赐教!!

05-09-07 sunlight2
我的jsp代码如下:(在同一个jsp页面中的)

<jsp:plugin type="applet" codebase="starmap" code="starmap.ZoneMonitorApplet.class" align="left" height="550" width="660" hspace="0" vspace="0" jreversion="1.4" />

<table width="299" height="516" border="0" align="center" cellspacing="1" bgcolor="#0000ff">

<tr>

<td width="295" height="25" bgcolor="#D6E6FC"><div align="center" class="style18">区域监控</div></td>

</tr>

<tr>

<td height="510" bordercolor="0" bgcolor="#D6E6FC" class="a1" cellspacing="1"><div align="center">

<jsp:plugin type="applet" codebase="starmap" name="friend" code="starmap.ZoneMonitorA.class" align="left" height="500" width="300" hspace="0" vspace="0" jreversion="1.4">

<jsp:params>

<jsp:param name="groupterminals" value="<%=gsGroupAndTerminals%>" />

</jsp:params>

<jsp:fallback>在插入Applet时产生错误</jsp:fallback>

</jsp:plugin>

</div></td>

</tr>

</table>

我在ZoneMonitorApplet中用如下方法,试图取得名为”friend“的applet:

ZoneMonitorA talker2=(ZoneMonitorA)getAppletContext().getApplet("friend");

if(talker2==null)

JOptionPane.showMessageDialog(null, "2222", "错误!", -1);

else

{

talker2.setUpLongitudeValue("11111111");

}

结果是talker2==null, 为什么会得不到要通信得applet的对象呢??

sunlight2
2005-09-07 18:04
代码变成了页面,我再把代码发一下:

<jsp:plugin type="applet" codebase="starmap" code="starmap.ZoneMonitorApplet.class" align="left" height="550" width="660" hspace="0" vspace="0" jreversion="1.4" /> 
<table width="299" height="516" border="0" align="center" cellspacing="1" bgcolor="#0000ff">
<tr>
<td width="295" height="25" bgcolor="#D6E6FC"><div align="center" class="style18">区域监控</div></td>
</tr>
<tr>
<td height="510" bordercolor="0" bgcolor="#D6E6FC" class="a1" cellspacing="1"><div align="center">
<jsp:plugin type="applet" codebase="starmap" name="friend" code="starmap.ZoneMonitorA.class" align="left" height="500" width="300" hspace="0" vspace="0" jreversion="1.4">
<jsp:params> 
<jsp:param name="groupterminals" value="<%=gsGroupAndTerminals%>" />
</jsp:params> 
<jsp:fallback>在插入Applet时产生错误</jsp:fallback>
</jsp:plugin>
</div></td>
</tr>
</table>

我在ZoneMonitorApplet中用如下方法,试图取得名为”friend“的applet:
ZoneMonitorA talker2=(ZoneMonitorA)getAppletContext().getApplet("friend"); 
if(talker2==null)
JOptionPane.showMessageDialog(null, "2222", "错误!", -1);
else
{
talker2.setUpLongitudeValue("11111111");
}

<p>

猜你喜欢