Tuesday, July 23, 2013

Expression Language in JSP not working (not getting evaluated)


process.jsp:
Welcome, ${param.name}

Page URL:
http://127.0.0.1:8888/myapp/process.jsp?name=test123

Expected ouptut:
Welcome, test123

With other words, the EL expression doesn't get evaluated? That can have one or more of the following causes:
  1. Application server in question doesn't support JSP 2.0.
  2. The web.xml is not declared as Servlet 2.4 or higher.
  3. The @page is configured with isELIgnored=true.
  4. The web.xml is configured with <el-ignored>true</el-ignored> in <jsp-config>.
In my case, it was Problem #2 so edit the web.xml file to include

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
...
</web-app>

No comments: