Andrew McDonough

Please note: This page is imported from my wiki, which hasn't been updated in over 10 years. Some of the formatting was lost during the import. I'll try to get around to fixing it someday.

JSP Custom Tags

Tag extension mechanism

extend the SimpleTagSupport class

all attributes are populated by calling standard setter methods

public class CustomMyTag extends SimpleTagSupport{ private String exampleString; public void setExampleString(String exampleString) { this.exampleString = exampleString; } public void doTag() throws IOException { JspWriter out = getJspContext().getOut(); out.println(“Hello”); } }

Evaluating Expressions

String eValue = ""; ExpressionEvaluator ee; VariableResolver vr = context.getVariableResolver();
ee = context.getExpressionEvaluator(); try { eValue = (String) ee.evaluate(value, String.class, vr, null); } catch (Exception e) {
}

${bean.value} is called an EL expression (Expression Language Expression)


Andrew McDonough

Andrew McDonough is a consultant CTO and software developer, currently based between Berlin and London.

Follow Andrew on Twitter or Connect on LinkedIn