Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artem-smotrakov/1a170502a59cb229c3b64759d067b631 to your computer and use it in GitHub Desktop.
Save artem-smotrakov/1a170502a59cb229c3b64759d067b631 to your computer and use it in GitHub Desktop.
Example of EL injection with JUEL
void handle(HttpRequest request) {
if (request.hasParameter("questionToBackend")) {
String expression = request.getParameter("questionToBackend"));
ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl();
ELContext context = new de.odysseus.el.util.SimpleContext();
ValueExpression e = factory.createValueExpression(context, expression, Object.class);
Object object = e.getValue(context);
handleResult(object);
} else {
callNextHandler(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment