0

I use websphere 8 and RAD 8 and this scriptlet output the correct value:

<%= ansokanInfo.getPSystem() %>

But using EL it outputs nothing:

${ansokanInfo.PSystem}

I can write anything between the ${ and } and it won't render. What am I doing wrong? what should be done to enable EL expressions? This is not working either:

<c:out value="${ansokanInfo.PSystem}" />

But this is working:

<c:forEach var="i" begin="1" end="5" >     <c:out value="${i}" />    </c:forEach> 

My web.xml starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" 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_2_5.xsd">
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424

1 Answers1

2

Scriptlets and EL do not share the same variable scope. Scriptlet variables are declared in JSP body, while EL variables are supposed to be set as an attribute of the page, request, session or application scope.

So, to make the ansokanInfo available in EL, you need to set it in one of those scopes. Assuming that it represents request scoped data, do so:

request.setAttribute("ansokanInfo", ansokanInfo);

You could do that in a scriptlet before the first EL evaluation of this variable ever. But more sensible would be to do that in a preprocessing servlet.

To learn and understand the concepts properly, check our wiki pages on the mandatory subjects:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555