if (encoding != null)
{
contentType = contentType + ";charset=" + encoding;
}
Template t = getTemplate(stack,
velocityManager.getVelocityEngine(), invocation,
finalLocation, encoding);
Context context = createContext(velocityManager, stack, request,
response, finalLocation);
Writer screenWriter = new StringWriter();
response.setContentType(contentType);
t.merge(context, screenWriter);
context.put(KEY_SCREEN_CONTENT, screenWriter.toString());
// ------------- 2. render the layout template -------------
initLayoutTemplateParameters();
String layout = getLayoutTemplate(context);
try
{
// load the layout template
t = getTemplate(stack, velocityManager.getVelocityEngine(),
invocation, layout, encoding);
}
catch (Exception e)
{
// if it was an alternate layout we couldn't get...
if (!layout.equals(defaultLayout))
{
// try to get the default layout
// if this also fails, let the exception go
t = getTemplate(stack, velocityManager.getVelocityEngine(),
invocation, defaultLayout, encoding);
}
}
Writer writer = new OutputStreamWriter(response.getOutputStream(),
encoding);
// Render the layout template into the response
t.merge(context, writer);
// generator exec template time
Date cur_time = Calendar.getInstance(
invocation.getInvocationContext().getLocale()).getTime();
writer.write("\r\n<!-- Generated by EATELE.NET (");