You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 滕训华 <te...@magic-sw.com.cn> on 2008/04/07 08:07:17 UTC
About redirect page
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)?
答复: About redirect page
Posted by 滕训华 <te...@magic-sw.com.cn>.
Thanks ,I will try.
-----邮件原件-----
发件人: Angelo Chen [mailto:angelochen960@yahoo.com.hk]
发送时间: 2008年4月7日 14:17
收件人: users@tapestry.apache.org
主题: Re: About redirect page
response.sendRedirect(request.getContextPath() + "/login");
return true;
txhdeve wrote:
>
> 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)?
>
>
>
--
View this message in context:
http://www.nabble.com/About-redirect-page-tp16534281p16534370.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: About redirect page
Posted by Angelo Chen <an...@yahoo.com.hk>.
response.sendRedirect(request.getContextPath() + "/login");
return true;
txhdeve wrote:
>
> 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)?
>
>
>
--
View this message in context: http://www.nabble.com/About-redirect-page-tp16534281p16534370.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org