RSS RSS feed | Atom Atom feed | |

Replacing scriptlets with expression language

Old dog looking for new way to do same old tricks

Some times new technologies seem to be created just to make the experienced people feel old. I noticed that some of the folks that were cutting edge when JSPs were introduced have been slow to embrace Expression Language (EL). I have to admit that after years of using it, I still find myself falling back to scriptlets when I'm prototyping. This is mostly because I already know how to write Java and taking the time to think in tags just slows me down.

One good example is getting the context path. Over the years this is a consistent question from experienced developers and a few newbies. In the old days a small scriptlet solved the problem:

<%= request.getContextPath() %>

Now the same task is handled by EL:

${pageContext.request.contextPath}

I don't think either are particularly elegant. They are just different. If you learned JSP back when it first came out, you are probably more productive with the first. The second is gaining on me but I still can't think in tags just like I never could think (or speak or read) in French back in high school.

If you are still struggling with EL, here is a good article that covers the basics so you can gain confidence with this approach.

Tags :



Add a comment Send a TrackBack