This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a bean function using jstl

 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i m calling a bean function and getting the error
The function ast must be used with a prefix when a default namespace is not specified

I m using using glassfish v2.1
I have the bean



The taglib


in jsp im having



the line ${u.ast()} gives the error message (thanks to Bear Bibeault)



else everything works fine such as



Any help

Thanks
Pradyut
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradyut Bhattacharya wrote: the line ${u.ast()} gives the problem

In the future, please be sure to include the error message -- not just say "gives a problem". (Please read this for more information.)

But in this case, I can tell you that the problem is that EL functions must be static. You can't call instance methods.




Why are you using getProperty in place of the EL?
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the fast reply

changed the code to



but still could not get solved. The same error message



thanks for quoting the getProperty but i was just showing they are working just fine...

regards
Pradyut

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use the TLD's namespace to invoke the function.
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could not understand tld namespace or wheres it located...

new to tld and namespaces :-(
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You created the namespace when you mapped the TLD:

So to call the function:


By the way, the URI you chose doesn't follow the usual convention. It should look like a URL (even though it's not a URL) using a domain that you own. That way, there's never any chance of it conflicting with some other library's URI.

 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Changed the uri to "http://pradyut.dyndns.org/newtag_library"

Thanks but still no change... the same error message
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to show your new files.

Are you sure that you are using a colon and not a dot to separate the namespace from the function name?
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow.. i didnt know the use of colons like that...
well the new exception thrown is...

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because it's not declared in your TLD. You must add a function element to define the function otherwise how is the JSP engine supposed to know anything about it?
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but in my tld i have



 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about that... now my tld is...



and in jsp i m calling



and still the error message



please rescue...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks pretty clear to me; the class cannot be found. Did you compile the bean and put the class file in the correct location?
 
Pradyut Bhattacharya
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bear Bibeault

you rocked it!!!

the tld should be

 
Varun Selva
Ranch Hand
Posts: 48
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the late comment.
I also found this same problem.
I got the solution by defining the method as static.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic