// initialization. Certain services need RunData to initialize
// themselves.
init(data);
// Get the instance of the Session Validator.
SessionValidator sessionValidator = (SessionValidator)ActionLoader
.getInstance().getInstance(TurbineResources.getString(
"action.sessionvalidator"));
// if this is the redirected stage of the initial request,
// check that the session is now not new.
// If it is not, then redirect back to the
// original URL (i.e. remove the "redirected" pathinfo)
if (data.getParameters()
.getString(REDIRECTED_PATHINFO_NAME, "false").startsWith("true"))
{
if (data.getSession().isNew())
{
String message = "Infinite redirect detected...";
log(message);
Log.error(message);
throw new Exception(message);
}
else
{
DynamicURI duri = new DynamicURI (data, true);
// Pass on the sent data in pathinfo.
for (Enumeration e = data.getParameters().keys() ;
e.hasMoreElements() ;)
{
String key = (String) e.nextElement();
if (!key.equals(REDIRECTED_PATHINFO_NAME))
{
String value =
(String) data.getParameters().getString ( key );
duri.addPathInfo((String)key, (String)value );
}
}
data.getResponse().sendRedirect( duri.toString() );
return;
}
}
else
{
// Insist that the client starts a session before access
// to data is allowed. this is done by redirecting them to
// the "screen.homepage" page but you could have them go
// to any page as a starter (ie: the homepage)
// "data.getResponse()" represents the HTTP servlet
// response.
if ( sessionValidator.requiresNewSession(data) &&
data.getSession().isNew() )
{
DynamicURI duri = new DynamicURI (data, true);
// Pass on the sent data in pathinfo.