The function getMessageData must be used with a prefix when a default namespace is not specified [duplicate]
Asked Answered
B

2

8

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"

Bobettebobina answered 23/9, 2013 at 14:4 Comment(0)
A
13

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.

Aquarist answered 23/9, 2013 at 15:21 Comment(2)
Guess I'm a little out of date on my EL, I wasn't aware they'd added parameter supportMantua
@Mantua That's no problem. We all find out something new on a daily basis here!Aquarist
M
6

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.)

Mantua answered 23/9, 2013 at 14:7 Comment(8)
but my code is working on my local PC's tomcat.Bobettebobina
@GovindKamalaPrakashMalviya If it's working on your local PC then you've got something else different, because what you showed won't work - JSTL doesn't support directly calling methods the way you're attempting to do. Try this and see if the problem goes awayMantua
getting error : Unable to find method [messageData] with [0] parametersBobettebobina
What is the java type of usermap?Mantua
UserMap class (user defined)Bobettebobina
Tomcat version on server is "Tomcat 6.0"Bobettebobina
I have updated tomcat version to 7 and now its working fine but still i couldn't understand what is exact issue.Bobettebobina
Though your answer may provide for a way of achieving the desired effect, it doesn't answer the question why. Provided information so far doesn't allow to judge it. The most possible reason is that the tomcat that webapp is deployed to doesn't have EL 2.2+ thius being Tomcat 6, while the localhost's a Tomcat 7.Aquarist

© 2022 - 2024 — McMap. All rights reserved.