Java.Servlet.How to disable the ability to use EL in JSP?

You can disable EL evaluation in a JSP page by setting the isELIgnored attribute to true in the page directive.

✅ Syntax:

<%@ page isELIgnored="true" %>

This tells the JSP engine to treat ${...} as plain text, not as an EL expression.

EL will be completely ignored in that page.

🔥 Example:

<%@ page isELIgnored="true" %>

<html>
<body>
  Hello, ${user.name}!
</body>
</html>

Result on browser:

Hello, ${user.name}!

The EL ${user.name} is not evaluated, just printed literally.

🛠️ How it Works Technically

AttributeMeaning
isELIgnored="false" (default)EL expressions are processed
isELIgnored="true"EL expressions are ignored and treated as normal text

📢 Important Notes:

  • By default, in JSP 2.0 and newer, EL is enabled (isELIgnored="false").
  • If you want to disable it globally (for all JSPs), you can configure it in web.xml (less common today).

Example (global disabling in web.xml):

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

This disables EL for all .jsp files matching the pattern.

🎯 Quick Summary

SettingEffect
isELIgnored="false" (default)EL expressions evaluated normally
isELIgnored="true"EL expressions ignored and output literally

🚀 In real projects today:

  • You almost never disable EL — it is considered the cleanest way to access dynamic data in JSP.
  • Disabling it might make sense only for special legacy pages or static template pages where ${} could conflict with text content.
This entry was posted in Без рубрики. Bookmark the permalink.