Applet和JSP通信
我想获取在客户端加载小程序后动态分配的变量的值。 Applet 嵌入在 JSP 页面中。我想在该 JSP 页面中获取该值。源代码如下:
public class CheckJavaVersion extends Applet
{
private static Label versionCheck;
public static String javaVersion;
public void init()
{
try
{
Color colFrameBackground = new Color(198, 0, 0);
this.setBackground(colFrameBackground);
versionCheck = new Label("Java Version:"+System.getProperty("java.version"));
this.add(versionCheck);
javaVersion = versionCheck.getText();
}
}
JSP 页面:
<html>
<head><title>Display Java Version</title>
</head>
<body>
<jsp:plugin code="com.applets.CheckJavaVersion" codebase="/AppletURLComm" type="applet">
</jsp:plugin>
</body>
</html>
现在我想访问JSP 页面中的javaversion
变量。如果我访问该变量,它会给出 null 值。如何获取变量的值?
I want to get the value of a variable which is dynamically assigned after the applet load in client side. Applet is embedded in a JSP page. Within that JSP page I want to get that value. Source code is given below:
public class CheckJavaVersion extends Applet
{
private static Label versionCheck;
public static String javaVersion;
public void init()
{
try
{
Color colFrameBackground = new Color(198, 0, 0);
this.setBackground(colFrameBackground);
versionCheck = new Label("Java Version:"+System.getProperty("java.version"));
this.add(versionCheck);
javaVersion = versionCheck.getText();
}
}
JSP Page:
<html>
<head><title>Display Java Version</title>
</head>
<body>
<jsp:plugin code="com.applets.CheckJavaVersion" codebase="/AppletURLComm" type="applet">
</jsp:plugin>
</body>
</html>
Now I want to access the javaversion
variable in the JSP page. If I access that variable, it is giving null
value. How to get the variable with value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与JSP无关。您想要获取驻留在客户端(小程序)上的变量。所以你必须使用 javascript 来完成此操作。 请参见此处 和 此处
This has nothing to do with JSP. You want to obtain a variable that resides on the client (applet). So you have to do this with javascript. See here and here
我编译了代码并转换为jar文件并签名
将jar文件放入jsp文件中
I compiled the code and convert into jar file and signed
Put the jar file into jsp file