JSP bean获取各种参数
程序员文章站
2023-11-26 19:37:58
1.包: 复制代码 代码如下: package beanpackage; /** * * @author lucifer */ public class systempro...
1.包:
package beanpackage;
/**
*
* @author lucifer
*/
public class systemproperties {
public string getruntimeenvironmentversion(){
return system.getproperty("java.version");
}
public string getruntimeenvironmentvendor(){
return system.getproperty("java.vendor");
}
public string getvmversion(){
return system.getproperty("java.vm.version");
}
public string getvmvendor(){
return system.getproperty("java.vm.vendor");
}
public string getvmname(){
return system.getproperty("java.vm.name");
}
public string getvmspecversion(){
return system.getproperty("java.vm.specification.version");
}
public string getvmspecvendor(){
return system.getproperty("java.vm.specification.vendor");
}
public string getvmspecname(){
return system.getproperty("java.vm.specification.name");
}
public string getrtespecname(){
return system.getproperty("java.specification.name");
}
public string getrtespecversion(){
return system.getproperty("java.specification.version");
}
public string getrtespecvendor(){
return system.getproperty("java.specification.vendor");
}
public string getoperatingsystemname(){
return system.getproperty("os.name");
}
public string getoperatingsystemversion(){
return system.getproperty("os.version");
}
public string getoperatingsystemarchitecture(){
return system.getproperty("os.arch");
}
}
2.jsp代码:
<%--
document : usebean
created on : 2009-10-3, 13:06:24
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<jsp:usebean id="properties" class="beanpackage.systemproperties"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jsp page</title>
</head>
<body>
operating system name:
<jsp:getproperty name="properties" property="operatingsystemname"/>
<br>
operating system version:
<jsp:getproperty name="properties" property="operatingsystemversion"/>
<br>
operating system architecture:
<jsp:getproperty name="properties" property="operatingsystemarchitecture"/>
<br>
<br>
runtime environment version(jdk version):
<jsp:getproperty name="properties" property="runtimeenvironmentversion"/>
<br>
runtime environment vendor(jdk vendor):
<jsp:getproperty name="properties" property="runtimeenvironmentvendor"/>
<br>
<br>
vm version:
<jsp:getproperty name="properties" property="vmversion"/>
<br>
vm vendor:
<jsp:getproperty name="properties" property="vmvendor"/>
<br>
vm name:
<jsp:getproperty name="properties" property="vmname"/>
<br>
<br>
rte specification version:
<jsp:getproperty name="properties" property="rtespecversion"/>
<br>
rte specification vendor:
<jsp:getproperty name="properties" property="rtespecvendor"/>
<br>
rte specification name:
<jsp:getproperty name="properties" property="rtespecname"/>
<br>
<br>
vm specification name:
<jsp:getproperty name="properties" property="vmspecname"/>
<br>
vm specification version:
<jsp:getproperty name="properties" property="vmspecversion"/>
<br>
vm specification vendor:
<jsp:getproperty name="properties" property="vmspecvendor"/>
</body>
</html>
3.输出:
operating system name: windows vista
operating system version: 6.0
operating system architecture: x86
runtime environment version(jdk version): 1.6.0_16
runtime environment vendor(jdk vendor): sun microsystems inc.
vm version: 14.2-b01
vm vendor: sun microsystems inc.
vm name: java hotspot(tm) client vm
rte specification version: 1.6
rte specification vendor: sun microsystems inc.
rte specification name: java platform api specification
vm specification name: java virtual machine specification
vm specification version: 1.0
vm specification vendor: sun microsystems inc.
复制代码 代码如下:
package beanpackage;
/**
*
* @author lucifer
*/
public class systemproperties {
public string getruntimeenvironmentversion(){
return system.getproperty("java.version");
}
public string getruntimeenvironmentvendor(){
return system.getproperty("java.vendor");
}
public string getvmversion(){
return system.getproperty("java.vm.version");
}
public string getvmvendor(){
return system.getproperty("java.vm.vendor");
}
public string getvmname(){
return system.getproperty("java.vm.name");
}
public string getvmspecversion(){
return system.getproperty("java.vm.specification.version");
}
public string getvmspecvendor(){
return system.getproperty("java.vm.specification.vendor");
}
public string getvmspecname(){
return system.getproperty("java.vm.specification.name");
}
public string getrtespecname(){
return system.getproperty("java.specification.name");
}
public string getrtespecversion(){
return system.getproperty("java.specification.version");
}
public string getrtespecvendor(){
return system.getproperty("java.specification.vendor");
}
public string getoperatingsystemname(){
return system.getproperty("os.name");
}
public string getoperatingsystemversion(){
return system.getproperty("os.version");
}
public string getoperatingsystemarchitecture(){
return system.getproperty("os.arch");
}
}
2.jsp代码:
复制代码 代码如下:
<%--
document : usebean
created on : 2009-10-3, 13:06:24
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<jsp:usebean id="properties" class="beanpackage.systemproperties"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jsp page</title>
</head>
<body>
operating system name:
<jsp:getproperty name="properties" property="operatingsystemname"/>
<br>
operating system version:
<jsp:getproperty name="properties" property="operatingsystemversion"/>
<br>
operating system architecture:
<jsp:getproperty name="properties" property="operatingsystemarchitecture"/>
<br>
<br>
runtime environment version(jdk version):
<jsp:getproperty name="properties" property="runtimeenvironmentversion"/>
<br>
runtime environment vendor(jdk vendor):
<jsp:getproperty name="properties" property="runtimeenvironmentvendor"/>
<br>
<br>
vm version:
<jsp:getproperty name="properties" property="vmversion"/>
<br>
vm vendor:
<jsp:getproperty name="properties" property="vmvendor"/>
<br>
vm name:
<jsp:getproperty name="properties" property="vmname"/>
<br>
<br>
rte specification version:
<jsp:getproperty name="properties" property="rtespecversion"/>
<br>
rte specification vendor:
<jsp:getproperty name="properties" property="rtespecvendor"/>
<br>
rte specification name:
<jsp:getproperty name="properties" property="rtespecname"/>
<br>
<br>
vm specification name:
<jsp:getproperty name="properties" property="vmspecname"/>
<br>
vm specification version:
<jsp:getproperty name="properties" property="vmspecversion"/>
<br>
vm specification vendor:
<jsp:getproperty name="properties" property="vmspecvendor"/>
</body>
</html>
3.输出:
operating system name: windows vista
operating system version: 6.0
operating system architecture: x86
runtime environment version(jdk version): 1.6.0_16
runtime environment vendor(jdk vendor): sun microsystems inc.
vm version: 14.2-b01
vm vendor: sun microsystems inc.
vm name: java hotspot(tm) client vm
rte specification version: 1.6
rte specification vendor: sun microsystems inc.
rte specification name: java platform api specification
vm specification name: java virtual machine specification
vm specification version: 1.0
vm specification vendor: sun microsystems inc.