+ " from " + request);
}
}
// Get a MarinerPageContext object.
final MarinerPageContext context;
if (enclosingRequestContext != null) {
context =
ContextInternals.getMarinerPageContext(
enclosingRequestContext);
} else {
context = volantisBean.createMarinerPageContext();
}
// Create and initialise the EnvironmentContext, do this after the
// MarinerPageContext has been allocated but before it has been
// initialised as this is needed during the initialisation.
environmentContext.initialise(context);
environmentContext.initialiseSession();
ExpressionContext exprContext =
environmentContext.getExpressionContext();
// If there is an expression context then it must have been associated
// with an enclosing request context since we are still initialising
// this instance of MarinerServletRequestContext. We now must associate
// the expression context with this MarinerServletRequestContext.
//
// An expression context can be associated with more than one request
// context, although not concurrently. When the request context is no
// longer needed, the expression context (if any) should be reset to
// the enclosing request context.
if (exprContext == null) {
ExpressionSupport.createExpressionEnv(this,
volantisBean, environmentContext,
context.getDevicePolicyAccessor());
} else {
exprContext.setProperty(MarinerRequestContext.class, this,
false);
}
ContextInternals.setEnvironmentContext(this, environmentContext);
if (enclosingRequestContext != null) {
// Copy our application context, as nothing has changed from an
// application point of view.
appContext =
ContextInternals.getApplicationContext(
enclosingRequestContext);
if (logger.isDebugEnabled()) {
logger.debug("Retrieved applicationContext " + appContext);
}
} else {
// We are the top level request so initialise an application context
// for this application
appContext = acf.createApplicationContext(this);
if (logger.isDebugEnabled()) {
logger.debug(
"Created new applicationContext " + appContext);
}
}
// Store the application context away as it is required to
// initialise the page context.
ContextInternals.setApplicationContext(this, appContext);
// Save the reference away immediately so if a problem occurs during the
// initialisation it is cleaned up properly.
ContextInternals.setMarinerPageContext(this, context);
// Initialise the page context.
if (enclosingRequestContext == null) {
context.initialisePage(volantisBean, this,
enclosingRequestContext,
requestURL, requestHeaders);
} else {
// Make this the current request context
context.pushRequestContext(this);
}
// Select the best charset that we could find from the accept headers.
EncodingManager encodingManager = appContext.getEncodingManager();
AcceptCharsetSelector selector = new AcceptCharsetSelector(
encodingManager);
HttpHeaders rHeaders = HttpServletFactory.
getDefaultInstance().getHTTPHeaders(request);
String charset = selector.selectCharset(rHeaders,
(DefaultDevice) context.getDevice().getDevice());
if (charset != null) {
// Use the selected charset.
// This should always succeed since we already validated it.
setCharacterEncoding(charset);
} else {