1 28 29 package com.caucho.jsp.java; 30 31 import com.caucho.jsp.JspParseException; 32 import com.caucho.vfs.WriteStream; 33 import com.caucho.xml.QName; 34 35 import java.io.IOException ; 36 37 public class JstlCoreCatch extends JstlNode { 38 private static final QName VAR = new QName("var"); 39 40 private String _var; 41 42 45 public void addAttribute(QName name, String value) 46 throws JspParseException 47 { 48 if (VAR.equals(name)) 49 _var = value; 50 else 51 throw error(L.l("`{0}' is an unknown attribute for <{1}>.", 52 name, getTagName())); 53 } 54 55 60 public void printXml(WriteStream os) 61 throws IOException 62 { 63 os.print("<c:catch"); 64 65 if (_var != null) 66 os.print(" var=\"" + xmlText(_var) + "\""); 67 68 os.print(">"); 69 70 printXmlChildren(os); 71 72 os.print("</c:catch>"); 73 } 74 75 78 public void generate(JspJavaWriter out) 79 throws Exception 80 { 81 String temp = "_jsp_out" + _gen.uniqueId(); 82 83 out.println("javax.servlet.jsp.JspWriter " + temp + " = out;"); 84 out.println("try {"); 85 out.pushDepth(); 86 87 generateChildren(out); 88 89 if (_var != null) 90 out.println("pageContext.removeAttribute(\"" + _var + "\");"); 91 92 out.popDepth(); 93 out.println("} catch (Throwable _jsp_exn) {"); 94 95 out.println(" out = pageContext.setWriter(" + temp + ");"); 96 97 if (_var != null) 98 out.println(" pageContext.setAttribute(\"" + _var + "\", _jsp_exn);"); 99 100 out.println("}"); 101 } 102 } 103 | Popular Tags |