Sethington
Technical User
What I'm doing is I have a website that sends a command property to a front controller servlet and then forwards onto a class. All that I want this class to do is get the command property and dynamically call the appropriate class and its method. For example if the command is "Login" then I want it to call the Login class and the "getLogin" method. I went searching around and here is what I have come up with so far but it throws a Class not found exception. Can anyone please help it is driving me crazy trying to figure this out.
Here is my source:
code:
INTERFACE
import java.sql.Connection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.Branch
public interface ApplicationControllerInterface {
public HttpServletResponse getRule(HttpServletRequest request, HttpServletResponse response, Connection conn);
}
APP CONTROLLER CLASS
import com.BranchBCO;
public class HTBApplicationController implements ApplicationControllerInterface {
public static void requestBusinessControlObject(HttpServletRequest request, HttpServletResponse response, Connection conn) {
try {((ApplicationControllerInterface)(Class.forName((String)request.getParameter("cmd")+"BCO").newInstance())).doRequest(request, response, conn);
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (ClassNotFoundException e) {
}
}
Here is my source:
code:
INTERFACE
import java.sql.Connection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.Branch
public interface ApplicationControllerInterface {
public HttpServletResponse getRule(HttpServletRequest request, HttpServletResponse response, Connection conn);
}
APP CONTROLLER CLASS
import com.BranchBCO;
public class HTBApplicationController implements ApplicationControllerInterface {
public static void requestBusinessControlObject(HttpServletRequest request, HttpServletResponse response, Connection conn) {
try {((ApplicationControllerInterface)(Class.forName((String)request.getParameter("cmd")+"BCO").newInstance())).doRequest(request, response, conn);
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (ClassNotFoundException e) {
}
}