##### Commons SCXML Resources

- Overview
- User Guide
  - SCXML documents
  - Using Commons SCXML
  - Standalone Testing
  - SCXML Digester
  - SCXML datamodel
  - Contexts and Evaluators
  - SCXML Engine
  - Triggering Events
  - Custom Actions
  - Custom Semantics
  - Side Effect - EL
- Javadoc
- FAQ
- Usecases
- Building
- Dependencies
- Mailing lists
- Team
- SVN repository
- Nightly snapshots

##### Project Documentation

- About
- Project Info
- Project Reports
- Development Process

##### Commons

- Home
- Components
- Sandbox
- Dormant
- Volunteering
- Contributing Patches
- Building Components
- Releasing Components
- Wiki

##### Legend

- External Link
- Opens in a new window

## Commons SCXML - Trying out EL without the servlet container

Someone asked about Commons EL:
"Is there no way to test this stuff outside of a Servlet/JSP container?"

Commons SCXML supports EL as an expression language that may be used within the expressions in an SCXML document. As a side-effect, a simple API may be available for anyone who has the need to test without wanting to deal with a Servlet/JSP container. We understand this has limited use.

To test an expression language implementation, one minimally needs a context of evaluation and an evaluator, which gives us the following usage:

       //import org.apache.commons.scxml.Context;
       //import org.apache.commons.scxml.Evaluator;
       //import org.apache.commons.scxml.SCXMLExpressionException;
       //import org.apache.commons.scxml.env.jsp.ELContext;
       //import org.apache.commons.scxml.env.jsp.ELEvaluator;

       Context context = new ELContext();
       // Say we have an instance 'foo' of type Foo which
       // has a property 'bar' of type String
       context.set("foo", foo);

       Evaluator evaluator = new ELEvaluator();

       String bar = null;
       try {
         bar = (String) evaluator.eval(context, "${foo.bar}");
       } catch (SCXMLExpressionException see) {
         // Commons SCXML wraps the underlying exception,
         // in this case, a javax.servlet.jsp.el.ELException
       }