import java.io.IOException; import org.apache.tapestry.services.Request; import org.apache.tapestry.services.Response; public class AccessController implements Dispatcher { public boolean dispatch(Request request, Response response) throws IOException { boolean canAccess = false; /* * Access control logic goes here. If the user is allowed to access the * resource, canAccess should be set to true. */ if(!canAccess) { /* * This is an unauthorized request, so throw an exception. We'll need * more grace than this, such as a customized exception page and/or * redirection to a login page... */ throw new RuntimeException("Access violation!"); } return false; } }
I learn the dispatcher from wiki page of tapestry and I notice the sentence: This is an unauthorized request, so throw an exception. We'll need * more grace than this, such as a customized exception page and/or * redirection to a login page... But how to redirect a friendly page (exception page or login page)?