I think the only server that supported that out of the box was Netscape iPlanet, and that's long gone.
But a web app could use JavaScript scripts to do any number of things (say, for configuration or customization). There's a very capable JavaScript implementation written in
Java that you could use for this; it's called Rhino and is available at www.mozilla.org/rhino. (Starting with Java 6, it's also part of Java SE, and can be used through the javax.scripting API).