// Command action
@CommandAction()
public String navConnect() {
return "CLIENT_connect.jsp";
}
// "UnknownCommandActionException" is thrown and action.getAnnotations().length is 0, but action is navConnect
public String execute() throws UnknownCommandActionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
String actParam = getRequest().getParameter("act");
Method action = null;
try {
action = this.getClass().getMethod(actParam);
} catch (NoSuchMethodException e) {
throw new UnknownCommandActionException();
}
System.out.println(action.getName()); // prints out the right method name
if (action.getAnnotation(CommandAction.class) == null) {
throw new UnknownCommandActionException("execute() access to nonCommandAction attempted");
}
return (String) action.invoke(this);
}