001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry;
016
017 import org.apache.hivemind.ApplicationRuntimeException;
018
019 /**
020 * Exception thrown to force a redirection to an arbitrary location.
021 * This is used when, after processing a request (such as a form
022 * submission or a link being clicked), it is desirable to go
023 * to some arbitrary new location.
024 *
025 * @author Howard Lewis Ship
026 * @since 1.0.6
027 *
028 **/
029
030 public class RedirectException extends ApplicationRuntimeException
031 {
032 private static final long serialVersionUID = -9215837473156146010L;
033
034 private String _redirectLocation;
035
036 public RedirectException(String redirectLocation)
037 {
038 this(null, redirectLocation);
039 }
040
041 /**
042 * @param message A message describing why the redirection is taking place.
043 * @param redirectLocation The location to redirect to, may be a relative path (relative
044 * to the {@link javax.servlet.ServletContext}).
045 *
046 * @see javax.servlet.http.HttpServletResponse#sendRedirect(String)
047 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(String)
048 *
049 **/
050
051 public RedirectException(String message, String redirectLocation)
052 {
053 super(message);
054
055 _redirectLocation = redirectLocation;
056 }
057
058 public String getRedirectLocation()
059 {
060 return _redirectLocation;
061 }
062 }