目的: 在Javascript 利用Microsoft MXSML Engine来做XML/XSLT的ProtoTye开发.
传递一个XML的所谓.Result TRee Fragment 到XSLT 去处理.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml06192000.asp
例子:
关键处:MSXSL的DoMDocument的属性 .documentElement把一个node-set直接传递到XSLT中去处理.
MSXML:4.0 sp2.可能是个Bug.
<SCRIPT language = "javascript">
function init()
{
var basicinfo = new ActiveXObject("Msxml2.DOMDocument.4.0");
var employment = new ActiveXObject("Msxml2.DOMDocument.4.0");
var paycatagory = new ActiveXObject("Msxml2.DOMDocument.4.0");
var attendence = new ActiveXObject("Msxml2.DOMDocument.4.0");
var mainpage = new ActiveXObject("Msxml2.DOMDocument.4.0");
mainpage.async=false;
mainpage.resolveExternals = false;
basicinfo.async=false;
employment.async=false;
paycatagory.async=false;
attendence.async=false;
// You can substitute other XML file names here.
try
{
mainpage.load("hello.xml");
basicinfo.load("emp_M_Basicinfo.xml");
employment.load("emp_M_EmploymentInfo.xml");
paycatagory.load("pay_M_CatagoryItem.xml");
attendence.load("attendence.xml");
}catch(e)
{
alert("error:"+e.parseError);
}
//Display basicinfo nodeset
// alert(basicinfo.documentElement.childNodes.item(0).xml);
var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
var xsltTree= new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
xsltTree.async = false;
// You can substitute other XSLT file names here.
xsltTree.load("hello.xslt");
xslt.stylesheet = xsltTree
xslProc = xslt.createProcessor();
xslProc.input = mainpage
try
{
xslProc.addParameter("basicinfo",basicinfo.documentElement);//.selectNodes("/Results")
xslProc.addParameter("employment",employment);
xslProc.addParameter("paycatagory",paycatagory);
xslProc.addParameter("attendence",attendence);
xslProc.addParameter("yourname","William Wang");
}catch(e)
{
alert(e);
}
xslProc.transform();
resTree.innerHTML = xslProc.output;
// Save the result of the XSL transformation
//htmlCode = xslProc.output
//fso=new ActiveXObject("Scripting.FileSystemObject")
//htmlFile=fso.CreateTextFile("sample.html",true)
//htmlFile.WriteLine(htmlCode)
//htmlFile.Close()
}
</SCRIPT>
</HEAD>
<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>
</HTML>
星期二, 八月 31, 2004
星期五, 八月 20, 2004
j_Security_check 同Filter之间的矛盾
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21795
如果通过Filter来解决某些问题,在用户验证之前,Filter将不会被激活.
这是一个问题.
因为,j_security_check 有"remember me"功能,这样很多DBCS的参数将在Filter之前被编码.
如果通过Filter来解决某些问题,在用户验证之前,Filter将不会被激活.
这是一个问题.
因为,j_security_check 有"remember me"功能,这样很多DBCS的参数将在Filter之前被编码.
在Java里如何准确显示相除操作后的小数点位数
可以使用Formater族类.
一个常用的方法,使用BigDecimal类:
import java.math.BigDecimal;
import java.text.DecimalFormat;
public class testDe
{
public static void main(String[] args)
{
BigDecimal b1 = new BigDecimal(3);
BigDecimal b2 = new BigDecimal(12);
System.out.println(b1.divide(b2,2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
一个常用的方法,使用BigDecimal类:
import java.math.BigDecimal;
import java.text.DecimalFormat;
public class testDe
{
public static void main(String[] args)
{
BigDecimal b1 = new BigDecimal(3);
BigDecimal b2 = new BigDecimal(12);
System.out.println(b1.divide(b2,2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
星期四, 八月 12, 2004
JAAS and Form-Authenticate Invalid direct reference to form login page Solution
Tomcat
臭名昭著的:Invalid direct reference to form login page 异常
完全解决方法.
PreCondition:
不要直接访问Login页面,让Tomcat Container自己在需要的时候调用Login页面
其他的Callbacker和其他相关问题,参考2004.3月文章.
出现Invalid direct reference to form login page 的关键原因在web.xml中的配置有问题.
注意的问题,千万不要遗漏下面几行:
<realm-name>FDS<realm-name>
<auth-constraint>
<role-name></role-name>
</auth-constraint>
完整的例子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>ehrm</display-name>
<description>ehrm JAAS</description>
<filter>
<filter-name>encodecontroler</filter-name>
<filter-class>com.goldpeak.ehrm.services.EncodeControler</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodecontroler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-name>FMEntryPoint</servlet-name>
<servlet-class>com.gp.framework.control.web.MainServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FMEntryPoint</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/control/security/login</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/control/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name></role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>FDS</realm-name>
<form-login-config>
<form-login-page>/control/security/login</form-login-page>
<form-error-page>/config/error.jsp</form-error-page>
</form-login-config>
</login-config>
<!--security-role>
<description>A Funky User</description>
<role-name>FunkyUser</role-name>
</security-role-->
<env-entry>
<env-entry-name>DatabaseJNI</env-entry-name>
<env-entry-value>java:/MySqlDS</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
臭名昭著的:Invalid direct reference to form login page 异常
完全解决方法.
PreCondition:
不要直接访问Login页面,让Tomcat Container自己在需要的时候调用Login页面
其他的Callbacker和其他相关问题,参考2004.3月文章.
出现Invalid direct reference to form login page 的关键原因在web.xml中的配置有问题.
注意的问题,千万不要遗漏下面几行:
<realm-name>FDS<realm-name>
<auth-constraint>
<role-name></role-name>
</auth-constraint>
完整的例子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>ehrm</display-name>
<description>ehrm JAAS</description>
<filter>
<filter-name>encodecontroler</filter-name>
<filter-class>com.goldpeak.ehrm.services.EncodeControler</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodecontroler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-name>FMEntryPoint</servlet-name>
<servlet-class>com.gp.framework.control.web.MainServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FMEntryPoint</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/control/security/login</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/control/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name></role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>FDS</realm-name>
<form-login-config>
<form-login-page>/control/security/login</form-login-page>
<form-error-page>/config/error.jsp</form-error-page>
</form-login-config>
</login-config>
<!--security-role>
<description>A Funky User</description>
<role-name>FunkyUser</role-name>
</security-role-->
<env-entry>
<env-entry-name>DatabaseJNI</env-entry-name>
<env-entry-value>java:/MySqlDS</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
星期三, 八月 11, 2004
星期六, 八月 07, 2004
Google如何利用URLEncoder来处理事情。
红色的注释encodeURIComponent是关键。
<html><head><meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<script>
function qs()
{
el=document.mainform.chinese;
if (window.RegExp && window.encodeURIComponent)
{
var qe=encodeURIComponent(el.value);
prompt("Transmit",qe);
window.location.href="http://www.google.com/search?q="+qe+"&sourceid=firefox&start=0&start=0&ie=utf-8&oe=utf-8";
}
}
// -->
</script>
<body>
<form name="mainform">
<input type="text" name="chinese"><input type="button" value="Trasmition" onclick="qs()">
</form>
<html><head><meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<script>
function qs()
{
el=document.mainform.chinese;
if (window.RegExp && window.encodeURIComponent)
{
var qe=encodeURIComponent(el.value);
prompt("Transmit",qe);
window.location.href="http://www.google.com/search?q="+qe+"&sourceid=firefox&start=0&start=0&ie=utf-8&oe=utf-8";
}
}
// -->
</script>
<body>
<form name="mainform">
<input type="text" name="chinese"><input type="button" value="Trasmition" onclick="qs()">
</form>
星期二, 八月 03, 2004
常用词汇
YMMV:
----------------
"YMMV Net-language for 'your mileage may vary'. A warning that not everything described in a manual will work exactly the way it promised to. "
----------------
"YMMV Net-language for 'your mileage may vary'. A warning that not everything described in a manual will work exactly the way it promised to. "
星期一, 八月 02, 2004
JAAS术语说明
[Subject]:JAAS 用术语Subject来引用请求访问的资源的实体.
[Principals]:主体(或委托人).
[credential]:凭证或信任装(可以是密码或数字签名)
一个Subject可以是一个用户或一种服务.由于一个实体可能有多个名字,
或Principals
http://java.sun.com/j2se/1.4.2/docs/guide/security/jaas/tutorials/glossary.html
Subjects, Principals, Authentication, and Credentials
To authorize access to resources, applications first need to authenticate the source of the request. The JAAS framework defines the term subject to represent the source of a request. A subject may be any entity, such as a person or service. A subject is represented by the javax.security.auth.Subject class.
Authentication represents the process by which the identity of a subject is verified, and must be performed in a secure fashion; otherwise a perpetrator may impersonate others to gain access to a system. Authentication typically involves the subject demonstrating some form of evidence to prove its identity. Such evidence may be information only the subject would likely know or have (such as a password or fingerprint), or it may be information only the subject could produce (such as signed data using a private key).
Once authenticated, a Subject is populated with associated identities, or Principals (of type java.security.Principal). A Subject may have many Principals. For example, a person may have a name Principal ("John Doe") and an SSN Principal ("123-45-6789"), which distinguish it from other Subjects.
In addition to associated Principals, a Subject may own security-related attributes, which are referred to as credentials. A credential may contain information used to authenticate the subject to new services. Such credentials include passwords, Kerberos tickets, and public key certificates. Credentials might also contain data that simply enables the subject to perform certain activities. Cryptographic keys, for example, represent credentials that enable the subject to sign or encrypt data. Public and private credential classes are not part of the core JAAS class library. Any class, therefore, can represent a credential.
[Principals]:主体(或委托人).
[credential]:凭证或信任装(可以是密码或数字签名)
一个Subject可以是一个用户或一种服务.由于一个实体可能有多个名字,
或Principals
http://java.sun.com/j2se/1.4.2/docs/guide/security/jaas/tutorials/glossary.html
Subjects, Principals, Authentication, and Credentials
To authorize access to resources, applications first need to authenticate the source of the request. The JAAS framework defines the term subject to represent the source of a request. A subject may be any entity, such as a person or service. A subject is represented by the javax.security.auth.Subject class.
Authentication represents the process by which the identity of a subject is verified, and must be performed in a secure fashion; otherwise a perpetrator may impersonate others to gain access to a system. Authentication typically involves the subject demonstrating some form of evidence to prove its identity. Such evidence may be information only the subject would likely know or have (such as a password or fingerprint), or it may be information only the subject could produce (such as signed data using a private key).
Once authenticated, a Subject is populated with associated identities, or Principals (of type java.security.Principal). A Subject may have many Principals. For example, a person may have a name Principal ("John Doe") and an SSN Principal ("123-45-6789"), which distinguish it from other Subjects.
In addition to associated Principals, a Subject may own security-related attributes, which are referred to as credentials. A credential may contain information used to authenticate the subject to new services. Such credentials include passwords, Kerberos tickets, and public key certificates. Credentials might also contain data that simply enables the subject to perform certain activities. Cryptographic keys, for example, represent credentials that enable the subject to sign or encrypt data. Public and private credential classes are not part of the core JAAS class library. Any class, therefore, can represent a credential.
订阅:
博文 (Atom)