Hi all
I need help with dynamically loading classes using the forName(..) method of Class.
I have a servlet which gets a 'application name' as a parameter - 'application name'
is nothing but name of a Java class.
Say the 'application name' is "Ext1", we have a class called 'Ext1.class' containing a
set of methods.
public class Ext1 {
public static String returnSomething(String sParam1) {
return "return from Ext1.returnSomething() with argument=" + sParam1;
}
}
Now, my servlet contains the following code:
....
import java.lang.reflect.*;
....
String sApplName = "Ext1";
Class c = Class.forName (sApplName);
Object o = c.newInstance();
Now, I want to invoke 'returnSomething(..)' method and get the return string value.
How do I do it?
Any help will be highly appreciated. Thanks in advance.
Puneet
([EMAIL PROTECTED])
**********************************************************************
***** IMPORTANT INFORMATION *****
This document should be read only by those persons to whom
it is addressed and its content is not intended for use by
any other persons. If you have received this message in
error, please notify us immediately. Please also destroy and
delete the message from your computer. Any unauthorised form
of reproduction of this message is strictly prohibited.
St.George is not liable for the proper and complete transmission
of the information contained in this communication, nor for any
delay in its receipt.
**********************************************************************
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html