The global variables request
, prefix
, and
server
are already defined. Here's how to add a new
property:
sum = 3 + 4 + 5;
// total is different for every session
if (total == void) {
total = 1;
} else {
total++;
}
request.props.put("sum", Integer.toString(sum));
request.props.put("TOTAL", "Site accesses: " + total);
And here's a way to list the
properties contained in the request:
// It is poor practice to embed markup inside of scripts; we do it
// in this example to demonstate how to communicate between bsh
// and the rest of Brazil
e = request.props.propertyNames();
while (e.hasMoreElements()) {
name = e.nextElement();
value = request.props.getProperty(name);
print("" + name + " | " + value + " |
");
}
// add a new tag
void do_mytag() {
rewriteContext.append("I got my tag");
}
tagMap.put("mytag", "do_mytag();");
This is a new tag:
The end.