This question already has an answer here:
-
org.apache.jasper.JasperException: The function test must be used with a prefix when a default namespace is not specified
3 answers
I am getting this error
/WEB-INF/jsp/account/index.jsp(6,0) The function getMessageData must
be used with a prefix when a default namespace is not specified
<c:set var="messageData" scope="session" value="${usermap.getMessageData()}"/>
<c:set var="scheduleData" scope="session" value="${usermap.getScheduleData()}"/>
<c:set var="meetingData" scope="session" value="${usermap.getMeetingData()}"/>
Notice that I can run the same project on local Tomcat without any error.
Tomcat version on server is "Tomcat 6.0"
The problem with your code is that the code run locally is run on Tomcat 7 and the code run on the server is run on Tomcat 6.
As soon as invocation of methods with parameters (those ()
) is the feature of EL 2.2 (and higher) and it is accompanied by Servlet 3.0 compatible containers (thus Tomcat 7) your code runs fine locally.
As soon as this code is run on a Servlet 2.5 container (thus Tomcat 6) you get the mentioned error.
Still, "property-like" access (without ()
) is supported by both servlet containers.
Try this:
<c:set var="messageData" scope="session" value="${usermap.messageData}"/>
<c:set var="scheduleData" scope="session" value="${usermap.scheduleData}"/>
<c:set var="meetingData" scope="session" value="${usermap.meetingData}"/>
Reason is, EL removes the "get" and makes the first letter lower-case from your getter methods. Usually there's a field that matches the modified getter name, but it's not necessary.
(Actually, it's more the other way around - when you do usermap.messageData, EL automatically converts it to usermap.getMessageData(). If that method doesn't exist, you'll get an exception.)