//get the context from the request if possible
ChainedContext context;
if ( request.getAttribute( VelocityServlet.VELOCITY_CONTEXT ) != null && request.getAttribute( VelocityServlet.VELOCITY_CONTEXT ) instanceof ChainedContext ) {
return (ChainedContext) request.getAttribute( "velocityContext" );
} else {
RequestWrapper rw = new RequestWrapper( request );
if ( request.getAttribute( "User-Agent" ) != null && request.getAttribute( "User-Agent" ).equals( Constants.USER_AGENT_DOTCMS_BROWSER ) ) {
rw.setCustomUserAgentHeader( Constants.USER_AGENT_DOTCMS_BROWSER );
}
context = new ChainedContext( ctx, getEngine(), rw, response, Config.CONTEXT );
}
context.put("context", context);