Redirection

Redirection mechanism: Multi channel redirection

Redirection in DIF is handled by the controller. The typical HTTPServletResponse.sendRedirect("some url...") does not yield any result. DiF offers channel abstraction and thus redirection is oblivious to the request handling channel. This feature offers the ability to have the same stage serving requests from different channels.

Redirection: How to do it?

The following example shows how to redirect the execution flow to another stage. The IDIFContext interface provides a redirection method named redirectTo(String). The argument is the ID of the stage to redirect to, anotherStageID on the example.

@StageDefinition(name="This an example of a stage", service="aService")
public class SomeStage {

    @Execute
    public void action(IContext context) {
    
        if (true) // Some logic should be here...
            context.redirectTo("anotherStageID");
    } 
}

This method causes a new internal request that will run through the current channel dispatcher.

Back to User Guide index