Using Java Reflection how can i call a method which i specify in a JSP page.i mean if i have 3 methods in my java class when i specify one of my method name in Jsp page in a textbox when i submit the page that particular method has to be called using java Reflection

Showing Answers 1 - 1 of 1 Answers

Sandeep Virmani

  • Oct 14th, 2005
 

Please find below the reflection code :

 Object o = Class.forName(thisTable.getAttribute("classname")).newInstance();
                Method method = o.getClass().getDeclaredMethod("execute",new Class[]{HttpServletRequest.class});
                method.invoke(o, new Object[]{req});


In place of execute  you ned to specify your method name which you want to execute.(might me through textbox entry or from anywhere else.)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions