March 22, 2005

Using Expression Language in your own custom taglibs

I've written a couple of taglibs before to do simple things, but never realised how easy it was to use EL in your own tags.
public void setTarget(final String target) throws JspTagException {
try {
_target = (String) ExpressionEvaluatorManager.evaluate("target", target, String.class, pageContext);
} catch (JspException e) {
throw new JspTagException("Error:" + e.toString());
<mytag:dostuff target="${requestedUrl}" />
Simple as that. Using "" from the "standard.jar" jstl library, you can pass in EL expressions, such as "${mytarget}" and the ExpressionEvaluatorManager will look into the pageContext and turn that into real values just as any of the standard JSTL tags would do. Easy.

- No comments Not publicly viewable

Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

March 2005

Mo Tu We Th Fr Sa Su
Feb |  Today  | Apr
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31         


Search this blog

Most recent comments

  • One thing that was glossed over is that if you use Spring, there is a filter you can put in your XML… by Mathew Mannion on this entry
  • You are my hero. by Mathew Mannion on this entry
  • And may all your chickens come home to roost – in a nice fluffy organic, non–supermarket farmed kind… by Julie Moreton on this entry
  • Good luck I hope that you enjoy the new job! by on this entry
  • Good luck Kieran. :) by on this entry


Not signed in
Sign in

Powered by BlogBuilder