1 16 package org.apache.jetspeed.util.template; 17 18 import org.apache.log4j.Logger; 19 import org.apache.turbine.services.TurbineServices; 20 import org.apache.turbine.services.jsp.JspService; 21 import org.apache.turbine.util.RunData; 22 import org.apache.turbine.util.TurbineException; 23 24 30 public class JspTemplate 31 { 32 protected RunData runData; 33 protected String templateName; 34 private static Logger logger = Logger.getLogger(JspTemplate.class); 35 public JspTemplate(RunData runData, String templateName) 36 { 37 this.runData = runData; 38 this.templateName = templateName; 39 } 40 41 public String getContent() 42 { 43 JspService jsp = (JspService) TurbineServices.getInstance().getService(JspService.SERVICE_NAME); 44 try 45 { 46 jsp.handleRequest(this.runData, this.templateName); 47 } 48 catch (TurbineException te1) 49 { 50 if (!this.templateName.endsWith(".jsp")) 51 { 52 try 53 { 54 jsp.handleRequest(this.runData, this.templateName + ".jsp"); 55 } 56 catch (TurbineException te2) 57 { 58 logger.error("failed to invoke JSP Template '" + 59 this.templateName + "' and '" + this.templateName + ".jsp'", te2); 60 } 61 } 62 else 63 { 64 logger.error("failed to invoke JSP Template '" + this.templateName + "'", te1); 65 } 66 } 67 68 return ""; 69 } 70 } 71 | Popular Tags |