JSP, JSTL. The problem with variables and methods

I have a problem using jstl. I have it:

<jsp:useBean id="view" class="user.View"></jsp:useBean>
<jsp:useBean id="user" class="user.Validation" scope="session"></jsp:useBean>

<c:if test="${user.getValid() == 0}">
<c:out value="${view.printUserData(user)}"></c:out>
</c:if> 

and the class view looks like:

package user;

import java.lang.StringBuilder;

public class View {
    public String printUserData(Validation val) {
        String name = val.getImie();

        mainText.append(name);

        return mainText.toString();
    }

}

but I have an error:

org.apache.jasper.JasperException: /save.jsp (30.0) The getValid function should be used with a prefix when the default namespace is not specified

How can i fix this?

+5
source share
1 answer

The getValid function should be used with a prefix if no default namespace is specified

This error message is typical if you are not already using / starting a container that supports servlet 3.0, such as Tomcat 7, Glassfish 3, etc. Calling arbitrary methods in EL is not supported until Servlet 3.0.

, Servlet 3.0, .

<c:if test="${user.valid == 0}">

${view.printUserData(user)} -. EL.

<c:out value="${f:printUserData(view, user)}">

public static String printUserData(View view, Validation validation) {
    return view.printUserData(validation);
}
+9

All Articles