Hi there, Is there eval() on JSP or Servlet as there is in PHP and JScript? How can i evaluate a string using JAVA ? The problem is like this: I use a string ( that defines which function must be called) as parameter, i get it using getRequestParameter() and after that i want to call the function which has the same name as the string got , how can i do that ? Thanks
I feel the code given by James is a good start to work on with your requirements. Few points I noted w.r.t James code , you also have to Prefix the Package name. And I guess the typecasting is also not required .(you have to hardcode the className for typecasting in this case. This wouldn't possibly help you to execute dynamically)
How many possible values can this parameter have ( i.e. how many functions are there )? If there's not too many, why couldn't you use an if statement with the necessary else if blocks?
------------------ WebNelly.com Java/XML Web Development Check it out! http://www.webnelly.com
WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>