FileDocCategorySizeDatePackage
JspTemplateEngine.javaAPI DocExample3163Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components.template

JspTemplateEngine

public class JspTemplateEngine extends BaseTemplateEngine
JSP based template engine.

Fields Summary
private static final Log
LOG
Constructors Summary
Methods Summary
protected java.lang.StringgetSuffix()

        return "jsp";
    
public voidrenderTemplate(TemplateRenderingContext templateContext)


          
        Template template = templateContext.getTemplate();

        if (LOG.isDebugEnabled()) {
            LOG.debug("Trying to render template " + template + ", repeating through parents until we succeed");
        }
        UIBean tag = templateContext.getTag();
        ValueStack stack = templateContext.getStack();
        stack.push(tag);
        PageContext pageContext = (PageContext) stack.getContext().get(ServletActionContext.PAGE_CONTEXT);
        List templates = template.getPossibleTemplates(this);
        Exception exception = null;
        boolean success = false;
        for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
            Template t = (Template) iterator.next();
            try {
                Include.include(getFinalTemplateName(t), pageContext.getOut(),
                        pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
                success = true;
                break;
            } catch (Exception e) {
                if (exception == null) {
                    exception = e;
                }
            }
        }

        if (!success) {
            LOG.error("Could not render JSP template " + templateContext.getTemplate());

            if (exception != null) {
                throw exception;
            } else {
                return;
            }
        }

        stack.pop();