1

I am new to JSTL and looking for a way to call a method in a 'when' clause using JSTL. I import this way:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

And then I call the method using this syntax later in the JSP:

<c:when test= "${sessionBean.aBooleanMethod(form.userName)}" > 

The problem is, I get this error:

 ...contains invalid expression(s): javax.el.ELException: Error Parsing:  ${sessionBean.aBooleanMethod(form.userName)}

Please let me know if I need to include any more information or you have any questions! Thanks and I appreciate any answers/ideas!

Diana Amza
  • 303
  • 1
  • 2
  • 12
  • I already tried the solutions in that thread, for example this type of syntax "${bean.getArray(foo)}" doesn't work for me. I am using exactly the same: "${sessionBean.aBooleanMethod(form.userName)}" – Diana Amza Dec 03 '14 at 12:32
  • 1
    did you check that you are running a Servlet 3.0 compatible container (e.g. Tomcat 7, Glassfish 3, JBoss AS 6, etc) with a web.xml declared conform Servlet 3.0. with EL 2.2 ? – AdrianS Dec 03 '14 at 12:38
  • Ugh yeah, I just realized that now! I have to use Jboss 5.2 so I cannot update to 6... I suppose I need to find a workaround in that case. Cheers for helping out! – Diana Amza Dec 03 '14 at 12:40
  • In the same link you can find out alternatives. – AdrianS Dec 03 '14 at 12:44

1 Answers1

0

Fixed. In this case, the easiest way to fix was is use a Boolean field in my form instead of using a method call and then test that field in JSTL:

<c:when test="${form.someBooleanField}">
Diana Amza
  • 303
  • 1
  • 2
  • 12