ESXXWeb应用服务器
ESXX 是一种Web应用服务器, Web应用程序执行JavaScript编写的(又名的ECMAScript )的服务器端。这是用Java编写的,除了J2SE 6.0 没有外部依赖。一切需要都被包装在一个单一的,可执行的JAR文件。在Linux , Mac OS X操作系统, Solaris操作系统, Windows或任何其他平台上的Java 6可用。
架构如下:
脚本示例:
<?xml version="1.0" ?>
<esxx xmlns="http://esxx.org/1.0/">
<handlers>
<http method="GET" uri="/" handler="showMessages" />
<http method="POST" uri="/" handler="addMessage" />
<stylesheet href="wall.xslt" />
</handlers>
</esxx>
<?esxx
var db = new URI("jdbc:h2:mem:wall");
if (db.query("SELECT count(*) AS cnt " +
"FROM information_schema.tables " +
"WHERE table_name = 'GUESTBOOK'").entry.cnt == 0) {
db.query("CREATE TABLE GUESTBOOK (name VARCHAR(32), message CLOB, date DATETIME);");
esxx.log.info("Created table GUESTBOOK");
}
function showMessages(req) {
return <wall>
{db.query("SELECT name, message, date FROM GUESTBOOK LIMIT 10", { $result: "entries" })}
<form/>
</wall>;
}
function addMessage(req) {
if (!req.query.name || !req.query.message) {
return <wall>
<error>Name and message must be non-empty.</error>
<form>
<name>{req.query.name}</name>
<message>{req.query.message}</message>
</form>
</wall>;
}
db.query("INSERT INTO GUESTBOOK(name, message, date) VALUES({name}, {message}, NOW());",
req.query);
esxx.log.info(req.query.name + " wrote: " + req.query.message);
return [303, {Location: req.env.SCRIPT_NAME}];
}
?>
评论