11

How can I enable EL expression in JSP version 2.0? Every time I'm getting EL expression as an String literal in the JSP as an output.

Here's the DD which the container is using to sending request to servlet, and then servlet dispating request to JSP:

    <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">

    <servlet>
    <servlet-name>check</servlet-name>
    <servlet-class>Welcome</servlet-class>

    </servlet>


<servlet-mapping>
<servlet-name>check</servlet-name>
<url-pattern>/Momma.do</url-pattern>
</servlet-mapping>

</web-app>

I've not ignored any el in JSP too. Am I still missing something?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Greenhorn
  • 328
  • 2
  • 6
  • 12

3 Answers3

16

Your web.xml file looks fine for JSP 2.0. If you are having problems accessing EL on specific pages try adding the following to the top of the individual JSP page:

<%@ page isELIgnored="false" %>

Since you are using JSP 2.0 I think that EL is ignored by default so you can can add the following to your web.xml to enable it for all pages:

<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-enabled>true</el-enabled>
    <scripting-enabled>true</scripting-enabled>
  </jsp-property-group>
</jsp-config>
Aleksi Yrttiaho
  • 8,266
  • 29
  • 36
amischiefr
  • 4,750
  • 2
  • 29
  • 22
0

for facet 2.5

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>true</el-ignored>
    <scripting-invalid>true</scripting-invalid>
  </jsp-property-group>
</web-app>
0

With the web.xml below scriplets and expression languages will be enabled on pages jsp explicitly:

WEB-INF\web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>false</el-ignored>
        <scripting-invalid>false</scripting-invalid>
    </jsp-property-group>
  </jsp-config>
</web-app>

https://docs.oracle.com/cd/E24329_01/web.1211/e21049/web_xml.htm#WBAPP545

danilo
  • 7,680
  • 7
  • 43
  • 46