• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reflection in JSP  RSS feed

 
Sanjay Saxena
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In all my JSPs I have a method with common name
validate(,,,)
I'm writing a common code which will be a include in all JSPs and that code will invoke this method validate(). validate() method has different signature in different JSP. I think this is possible to invoke this method using reflection.
I'm trying to use reflection as follows.
Class thisClass = this.getClass();
Method[] theMethods = thisClass.getMethods();
for (int i = 0; i < theMethods.length; i++) {
String methodString = theMethods[i].getName();
System.out.print("Name: " + methodString);
}
----------------------
what I see in the log that all the methods of HttpJspBase and Object class being listed but not the ones which I have defined in my JSP.
Can anybody help as what code should I use for the same.
_Sanjay
 
Siddhartha Bhattacharya
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code works fine. Maybe you should try to scroll up the console window. It should be the first method listed.
or try out.print instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!