Expression Language in Jsp Not Working

JSP EL ${stuff} syntax not working

Your web.xml is probably referencing the Servlet 2.3 spec, in which isELIgnored is set to true by default. If you reference the Servlet 2.4 spec instead, isELIgnored will be set to false by default.

If you want to reference the Servlet 2.4 spec, your web.xml header should look something like this:

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

EL expressions not evaluated in JSP

Yes, i have doctype in web.xml <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "java.sun.com/dtd/web-app_2_3.dtd"; >

Remove that <!DOCTYPE> from web.xml and make sure that the <web-app> is declared conform Servlet 2.4 or newer and all should be well.

A valid Servlet 3.0 (Tomcat 7, JBoss AS 6-7, GlassFish 3, etc) compatible web.xml look like below in its entirety, without any <!DOCTYPE>:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<!-- Config here. -->

</web-app>

For Servlet 3.1 (Tomcat 8, WildFly 8-11, GlassFish/Payara 4, etc) it look like below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<!-- Config here. -->

</web-app>

For Servlet 4.0 (Tomcat 9, WildFly 12-21, GlassFish/Payara 5, etc) it look like below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">

<!-- Config here. -->

</web-app>

For Servlet 5.0 (Tomcat 10, WildFly 22-26, GlassFish/Payara 6, etc) it look like below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">

<!-- Config here. -->

</web-app>

When using JSTL 1.1 or newer, you need to assure that your web.xml is declared in such way that the webapp runs in at least Servlet 2.4 modus, otherwise EL expressions won't work in the webapp.

When still having a Servlet 2.3 or older <!DOCTYPE> or <web-app> in web.xml, even though you already have a Servlet 2.4 or newer XSD, then it would still be forced to run in Servlet 2.3 or older modus, causing the EL expressions to fail.

The technical reason is, EL was originally part of JSTL 1.0 and not available in Servlet 2.3 / JSP 1.2 and older. In JSTL 1.1, EL was removed from JSTL and integrated in JSP 2.0, which goes along with Servlet 2.4. So, if your web.xml is declared to run the webapp in Servlet 2.3 or older modus, then JSP would expect to find EL in JSTL library, but this would in turn fail if it's a newer JSTL version, lacking EL.

See also:

  • Difference between JSP EL, JSF EL and Unified EL - for a history of EL
  • Our JSTL wiki page

JSP expression language not working when evaluating variables

i found the problem in my code due which i could not get the EL expresion evaluated.
so i am sharing it with everyone. it may be a very beginner's mistake thats what I am.
the problem was that i have not set the variable using setAtrribute(Expression,variable) .thats why i wasnt getting the value .

JSP (expression language) not working in java based configuration spring mvc

add <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
close the question and Thanks :D b

Expression Language in JSP not working while i am generating a xml file in Jsp

I often avoid empty lines at the top of text, doing:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%><%@ page contentType="text/xml" %><%@ page isELIgnored="false"
%><?xml version="2.5" encoding="UTF-8" standalone="no"?>

Whether this would help here is the question. Though you can do:

<c:out value='<?xml version="2.5" encoding="UTF-8" standalone="no"?>'
escapeXml="false"/>

EL is not working in jsp 3.1

You should be able to access a session attribute directly using :

 ${sessionScope.LOGIN.name}

PS : I recommand you to never put Java code into the JSP since the EL and the JSTL exist. This will be more readable ;)



Related Topics



Leave a reply



Submit