String sourceCode = null;
try {
JavaSnippetBean bean = (JavaSnippetBean)ManagedBeanUtil.getBean(FacesContext.getCurrentInstance(), "javaSnippetBean");
Class<JspFragment> jspClass = bean.getCompiledClass(jspClassName);
if(jspClass==null) {
JspCompiler compiler = new JspCompiler();
sourceCode = compiler.compileJsp(jsp, jspClassName);
if(false) {
pw.println("<pre>");
pw.println(HtmlUtil.toHTMLContentString(sourceCode, false));
pw.println("</pre>");
}
jspClass = bean.compileSnippet(jspClassName, sourceCode);
}
if(jspClass!=null) {
JspFragment f = jspClass.newInstance();
f.exec(new JspSampleWriter(pw),req,resp);
}
} catch(Throwable e) {
pw.println("Execution error");
pw.println("<pre>");
StringWriter sw = new StringWriter();
PrintWriter psw = new PrintWriter(sw);
if(e instanceof IExceptionEx) {
((IExceptionEx)e).printExtraInformation(psw);
psw.println("");
}
if(sourceCode==null) {
JspCompiler compiler = new JspCompiler();
sourceCode = compiler.compileJsp(jsp, jspClassName);
}
if(sourceCode!=null) {
printSourceCode(psw,sourceCode,true,-1);
//psw.println(HtmlUtil.toHTMLContentString(sourceCode, false));
}