rewrite-config-servlet 2.0.0.Beta3

org.ocpsoft.rewrite.servlet.config
Class Redirect

java.lang.Object
  extended by org.ocpsoft.rewrite.config.DefaultOperationBuilder
      extended by org.ocpsoft.rewrite.servlet.config.HttpOperation
          extended by org.ocpsoft.rewrite.servlet.config.Redirect
All Implemented Interfaces:
Operation, OperationBuilder, Parameterized

public class Redirect
extends HttpOperation
implements Parameterized

An Operation that performs redirects via HttpInboundServletRewrite.redirectPermanent(String) and HttpInboundServletRewrite.redirectTemporary(String)

Author:
Lincoln Baxter, III

Method Summary
 Set<String> getRequiredParameterNames()
           
 RegexParameterizedPatternBuilder getTargetExpression()
           
 void performHttp(HttpServletRewrite event, EvaluationContext context)
           
static Redirect permanent(String location)
          Create an Operation that issues a permanent Redirect ( 301 HttpServletResponse.SC_MOVED_PERMANENTLY ) to the given location.
 void setParameterStore(ParameterStore store)
           
static Redirect temporary(String location)
          Create an Operation that issues a temporary Redirect ( 302 HttpServletResponse.SC_MOVED_TEMPORARILY ) to the given location.
 String toString()
           
 
Methods inherited from class org.ocpsoft.rewrite.servlet.config.HttpOperation
perform
 
Methods inherited from class org.ocpsoft.rewrite.config.DefaultOperationBuilder
and
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

performHttp

public void performHttp(HttpServletRewrite event,
                        EvaluationContext context)
Specified by:
performHttp in class HttpOperation

permanent

public static Redirect permanent(String location)
Create an Operation that issues a permanent Redirect ( 301 HttpServletResponse.SC_MOVED_PERMANENTLY ) to the given location. If the given location is not the same as HttpServletRewrite.getAddress(), this will change the browser URL and result in a new request.

Note that in order to redirect to a resource within the ServletContext, you must prepend the ServletContext.getContextPath().

For example:
Redirect.permanent(contextPath + "/example/location.html")

The given location may be parameterized:

/store/global /store/{category}
/store/{category}/item/{itemId}
...

Parameters:
location - ParameterizedPattern specifying the target location.
See Also:
ConfigurationRuleParameterBuilder.where(String)

temporary

public static Redirect temporary(String location)
Create an Operation that issues a temporary Redirect ( 302 HttpServletResponse.SC_MOVED_TEMPORARILY ) to the given location. If the given location is not the same as HttpServletRewrite.getAddress(), this will change the browser URL and result in a new request.

Note that in order to redirect within the ServletContext, you must prepend the ServletContext.getContextPath().

For example:
Redirect.temporary(contextPath + "/example/location.html")

The given location may be parameterized:

/store/global /store/{category}
/store/{category}/item/{itemId}
...

Parameters:
location - ParameterizedPattern specifying the target location.
See Also:
ConfigurationRuleParameterBuilder.where(String)

getTargetExpression

public RegexParameterizedPatternBuilder getTargetExpression()

toString

public String toString()
Overrides:
toString in class Object

getRequiredParameterNames

public Set<String> getRequiredParameterNames()
Specified by:
getRequiredParameterNames in interface Parameterized

setParameterStore

public void setParameterStore(ParameterStore store)
Specified by:
setParameterStore in interface Parameterized

rewrite-config-servlet 2.0.0.Beta3

Copyright © 2013 OCPsoft. All Rights Reserved.