Sunday, July 29, 2007

Enabling Expression Language (EL) in JSP

You can do it in two ways:

  • Enable it for whole application : Put following in web.xml

    <jsp-config>
    <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>false</el-ignored>
    </jsp-property-group>
    </jsp-config>

  • Enable it for just one JSP page : put following at top of your JSP Page
    <%@ page isELIgnored="false" %>
Make sure when you use the first option you use 2.4 schema or above. i. e. your root tag in web .xml looks something like this.

< web-app id="WebApp" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

make sure you are using Jasper jars for JSP 2.0 or above.

No comments: