XML Server Getting Started
"" + edt_password.value + ""
);
try {
var outXML = xmlapi.XMLHTTPRequest("/Examples/Tutorial/EchoLogon.jsp", inXML);
var responseNode = outXML.documentElement;
if (responseNode.getAttribute("status")!="true") {
var exception = new Object();
exception.description = outXML.documentElement.text;
throw exception;
}
var yearFromNow = new Date();
yearFromNow.setTime(yearFromNow.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie("userid", edt_userid.value, yearFromNow, "/");
result = true;
} catch (e) {
util.messageBox("Login failed", e.description);
}
window.returnValue = result;
window.close();
}
function btn_cancel::onclick() {
window.returnValue = result;
window.close();
}
function window::onLoad() {
if (window.dialogArguments!=null)
edt_userid.value = window.dialogArguments;
}
The following lines assigns
cookie
named userid to the value of the validated logon id. The expiration of the cookie is set
for one year (or, to be precise, 365 days); the / symbol as the last argument makes this cookie accessible by all documents
within current context, i.e. entire Web Application. (The very implementation of the setCookie() API is contained in the file
/xmlsp/js/system.js)
var yearFromNow = new Date();
yearFromNow.setTime(yearFromNow.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie("userid", edt_userid.value, yearFromNow, "/");
Also note how
edt_userid
INPUT element gets populated with the value passed via
window.dialogArguments
in
window::onLoad() event handler.
Now let's see the revised script of the calling HTML page (
/Examples/Tutorial/step7.html
):
This window will not get active until user logs on ...
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |