Applet与JSP通信
我想得到一个变量的值,该变量在客户端加载小程序后动态赋值。小程序嵌入在JSP页面中。在该JSP页面中,我希望获得该值。源代码如下:Applet与JSP通信,jsp,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 Co
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>
显示Java版本
现在我想访问JSP页面中的
javaversion
变量。如果我访问该变量,它将给出null
值。如何获取具有值的变量?这与JSP无关。您希望获取驻留在客户端(小程序)上的变量。因此,您必须使用javascript来实现这一点。及
我编译了代码并将其转换为jar文件并签名
D:\Thumb\build\classes\thumb>keytool -genkey -keystore myKeystore -alias myself
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Ravi
What is the name of your organizational unit?
[Unknown]: abc
What is the name of your organization?
[Unknown]: abc
What is the name of your City or Locality?
[Unknown]: Lucknow
What is the name of your State or Province?
[Unknown]: UP
What is the two-letter country code for this unit?
[Unknown]: 91
Is CN=Ravi Thapa, OU=NIC, O=NIC, L=Lucknow, ST=UP, C=91 correct?
[no]: yes
Enter key password for <myself>
(RETURN if same as keystore password):
Re-enter new password:
D:\SECUGEN_DRIVERS\Thumb\build\classes\thumb>keytool -selfcert -alias myself -kystore myKeystore
Illegal option: -kystore
keytool -selfcert [OPTION]...
Generates a self-signed certificate
Options:
-alias <alias> alias name of the entry to process
-sigalg <sigalg> signature algorithm name
-dname <dname> distinguished name
-startdate <startdate> certificate validity start date/time
-validity <valDays> validity number of days
-keypass <arg> key password
-storetype <storetype> keystore type
-keystore <keystore> keystore name
-storepass <arg> keystore password
-providername <providername> provider name
-providerclass <providerclass> provider class name
-providerarg <arg> provider argument
-providerpath <pathlist> provider classpath
-v verbose output
Use "keytool -help" for all available commands
D:\SECUGEN_DRIVERS\Thumb\build\classes\thumb>keytool -list -keystore myKeystore
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 1 entry
myself, Apr 15, 2014, PrivateKeyEntry,
Certificate fingerprint (SHA1): 24:9C:50:D7:49:47:27:EB:87:9A:BA:89:F4:19:72:6A:02:AF:1B:3F
D:\SECUGEN_DRIVERS\Thumb\build\classes\thumb>jarsigner -keystore myKeystore Thumb.jar myself
Enter Passphrase for keystore:
jar signed.
Warning:
The signer certificate will expire within six months.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2014-07-14) or after any future revocation date.
D:\Thumb\build\classes\Thumb>keytool-genkey-keystore-myKeystore-alias我自己
输入密钥库密码:
重新输入新密码:
你的名字和姓氏是什么?
[未知]:拉维
您的组织单位名称是什么?
[未知]:abc
你的组织名称是什么?
[未知]:abc
你所在的城市或地区叫什么名字?
[未知]:勒克瑙
你所在的州或省叫什么名字?
[未知]:向上
这个单位的两个字母的国家代码是什么?
[不详]:91
CN=Ravi Thapa,OU=NIC,O=NIC,L=勒克瑙,ST=UP,C=91正确吗?
[否]:是的
输入的密钥密码
(如果与密钥库密码相同,则返回):
重新输入新密码:
D:\SECUGEN\u DRIVERS\Thumb\build\classes\Thumb>keytool-selfcert-alias my-kystore
非法选项:-kystore
密钥工具-自证书[选项]。。。
生成自签名证书
选项:
-要处理的条目的别名
-sigalg签名算法名称
-dname可分辨名称
-开始日期证书有效期开始日期/时间
-有效天数
-密钥传递密钥密码
-storetype密钥库类型
-密钥库名称
-storepass密钥库密码
-提供者名称提供者名称
-providerclass提供程序类名
-providerarg提供程序参数
-providerpath提供程序类路径
-详细输出
对所有可用命令使用“keytool-help”
D:\SECUGEN\u DRIVERS\Thumb\build\classes\Thumb>keytool-list-keystore-myKeystore
输入密钥库密码:
密钥库类型:JKS
密钥库提供程序:SUN
您的密钥库包含1个条目
我自己,2014年4月15日,私钥进入,
证书指纹(SHA1):24:9C:50:D7:49:47:27:EB:87:9A:BA:89:F4:19:72:6A:02:AF:1B:3F
D:\SECUGEN\u DRIVERS\Thumb\build\classes\Thumb>jarsigner-keystore myKeystore Thumb.jar
输入密钥库的密码短语:
jar签名。
警告:
签名者证书将在六个月内过期。
没有提供-tsa或-tsacert,并且这个jar没有时间戳。如果没有时间戳,用户可能无法在签名者证书到期日(2014-07-14)或任何未来撤销日期后验证此jar。
将jar文件放入jsp文件
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.File"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<meta http-equiv="cache-control" content="no-cache"/>
<script type="text/javascript">
function getVarData(){
var thumbImp = document.Applet1.getBase64FMR();
var thumbImpImage = document.Applet1.getBase64Image();
document.getElementById('varThumb').value = thumbImp;
document.getElementById('varThumbImage').value = thumbImpImage;
}
</script>
</head>
<body>
<table>
<tr>
<td>
<applet code="thumb.ThumbVerification" width="120" height="170" id="Applet1" name="AppletABC"
archive="<%=request.getContextPath()%>/Thumb.jar"></applet>
</td>
</tr>
</table>
</body>
</html>
SEND THE DATA USING HIDDEN FIELD
<input type="submit" value=" SAVE " onclick="getVarData();"/>
<input type="hidden" id="varThumb" name="varThumb"/>
<input type="hidden" id="varThumbImage" name="varThumbImage"/>*
函数getVarData(){
var thumbImp=document.Applet1.getBase64FMR();
var thumbImpImage=document.Applet1.getBase64Image();
document.getElementById('varThumb')。value=thumbImp;
document.getElementById('varThumbImage')。value=thumbImpImage;
}
使用隐藏字段发送数据
*
非常有用的链接:)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.File"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<meta http-equiv="cache-control" content="no-cache"/>
<script type="text/javascript">
function getVarData(){
var thumbImp = document.Applet1.getBase64FMR();
var thumbImpImage = document.Applet1.getBase64Image();
document.getElementById('varThumb').value = thumbImp;
document.getElementById('varThumbImage').value = thumbImpImage;
}
</script>
</head>
<body>
<table>
<tr>
<td>
<applet code="thumb.ThumbVerification" width="120" height="170" id="Applet1" name="AppletABC"
archive="<%=request.getContextPath()%>/Thumb.jar"></applet>
</td>
</tr>
</table>
</body>
</html>
SEND THE DATA USING HIDDEN FIELD
<input type="submit" value=" SAVE " onclick="getVarData();"/>
<input type="hidden" id="varThumb" name="varThumb"/>
<input type="hidden" id="varThumbImage" name="varThumbImage"/>*