martes, 29 de abril de 2008

jsp expression language variables in jsp scriptlets

Well. i'm starting to work with java server pages expression language (EL). I don't understand why is recommended to use EL instead of java scriptlets in jsps, but i'm using it anyway.

Yesterday I needed to use a value stored in an EL variable. (i.e: ${elVar}) in a java scriptlet (i.e: <%...%>). Well, i was all the day looking how to do this. Well the solution (in my case):

<% /* java scriptlet accessing the EL variable ${elVar} */
String elVar = pageContext.findAttribute("elVar");
%>


hope this saves some programmer time