}
// 1) determine what JSP to forward to
String jspId = mController.getJspToRender();
if (jspId == null) {
throw new PortalException("No JSP id returned by controller.");
}
String jsp = mJspMap.getProperty(jspId);
boolean relativeToController = false;
if (jsp == null) {
throw new PortalException("No mapping available for JSP id '"
+ jspId + "'.");
}
if (! jsp.startsWith("/"))
{
relativeToController = true;
jsp =
mController.getClass().getPackage().getName().replace('.', '/')
+ "/"
+ jsp;
}
String prefix = "";
// jsps deployed from a car are deployed in configurable location.
if (relativeToController ||
mDeploymentApproach.get(mControllerClassname) == CAR_DEPLOYMENT)
{
prefix = getJspContextPath();
}
// 2) create req/res wrappers and push in model objects returned
// from controller.
HttpRequestFacade reqF = new HttpRequestFacade(mRequest);
HttpResponseFacade respF = new HttpResponseFacade(mResponse);
if (mObjects != null)
{
for (Iterator itr = mObjects.entrySet().iterator(); itr.hasNext();)
{
Map.Entry entry = (Entry) itr.next();
reqF.setAttribute((String) entry.getKey(), entry.getValue());
}
}
// 3) Add baseActionUrl and baseMediaUrl to the request object.
// Since classes and JSPs get deployed in some context relative
// classpath accessible area as determined by the Deployer's
// getRealPath() the classes will always be loaded by the non-car class
// loader. Therefore, we can't use traditional ways of determining
// if the channel was deployed via CAR and the images are still
// embedded therein. So we use this map which is updated during
// deployment checks to tell in which way the channel is deployed.
if (mControllerClassname != null)
{
reqF.setAttribute(
"baseMediaUrl",
runtimeData.getBaseMediaURL(mControllerClassname));
reqF.setAttribute("baseActionUrl", runtimeData.getBaseActionURL(true));
reqF.setAttribute("userLocale", runtimeData.getLocales()[0]);
}
// 4 render the JSP for the channel
String jspPath = prefix + jsp;
/*
* When we converted to tomcat we started seeing jsp channel content
* being swapped and some jsp's not getting their expected models
* resulting in exceptions. The problem was traced to dispatching
* somehow getting crossed. Therefore, we synchronize on the request
* to serialized all jsp rendering for a single user request if
* configured to do so.
*/
if (cSerializeJspRendering)
{
synchronized(mRequest)
{
renderJsp(jspPath, reqF, respF);
}
}
else
{
renderJsp(jspPath, reqF, respF);
}
// 5) if rendering successful, extract characters and use for our UI.
if (respF.isSuccessful())
{
pw.print(respF.getCharacters());
}
else
{
throw new PortalException(
"A problem occurred rendering JSP '"
+ jspPath
+ "'. Response Error Code: "
+ respF.getErrorCode()
+ (respF.getErrorMessage() != null