static String evaluate(PageContext pageContext, String body) throws JspException {
        Matcher matcher = TOKEN_PATTERN.matcher(body);
        StringBuffer result = new StringBuffer();

        // Find any tokens that need to be replaced
        while (matcher.find()) {
            String[] parts = matcher.group(2).split("\\.");
            Object var = null;

            try {
                var = pageContext.findAttribute(parts[0]);
            } catch (RuntimeException e) {
                /* Ignore this exception, most likely NPE which will be handled by var initialized as null above */
            }

            if (parts.length > 1) {
                for (int i=1; i<parts.length; i++) {
                    try {
                        // Gracefully handle NullPointerException
                        if (var == null) break;

                        Class clazz = var.getClass();
                        Method method = clazz.getMethod("get" + parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1));
                        var = method.invoke(var);
                    }
                    catch (NoSuchMethodException e) {
                        throw new JspException(e);
                    }
                    catch (InvocationTargetException e) {
                        throw new JspException(e);
                    }
                    catch (IllegalAccessException e) {
                        throw new JspException(e);
                    }
                }
            }

            // Display an empty string as opposed to "null"
            if (var == null) {
                var = "";
            }

            matcher.appendReplacement(result, String.valueOf(var));
        }
        matcher.appendTail(result);

        return result.toString();
    }