Vita Rara: A Life Uncommon

Redirect to referrer

You could do something like this.

In the action class

public void prepare() throws Exception {

if ( request != null ) {
String referer = request.getHeader( "Referer" );
logger.debug(this, "prepare()","referer is '%'", referer);
if ( referer != null ) {
setRedirectUrl( referer );
} else {
setRedirectUrl( request.getContextPath() );
}

}

In the struts configuration


<action name="loginCommit" class="loginAction" method="loginCommit">
<result name="input" type="redirect">${redirectUrl}</result>
<result name="success" type="redirect"\>${redirectUrl}</result>
</action>

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
  • Allowed HTML tags: <a> <img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <h1> <h2> <h3>
  • Lines and paragraphs break automatically.
More information about formatting options