1 28 29 package com.caucho.jsp.java; 30 31 import com.caucho.jsp.JspParseException; 32 import com.caucho.xml.QName; 33 34 abstract public class JstlNode extends JspContainerNode { 35 38 public void addAttribute(QName name, String value) 39 throws JspParseException 40 { 41 throw error(L.l("`{0}' is an unknown attribute for <{1}>.", 42 name.getName(), getTagName())); 43 } 44 45 53 protected void generateSetNotNull(JspJavaWriter out, String var, 54 String scope, String value) 55 throws Exception 56 { 57 if (var == null) { 58 } 59 else if (scope == null || scope.equals("page")) { 60 out.println("pageContext.setAttribute(\"" + var + "\", " + value + ");"); 61 } 62 else if (scope.equals("request")) { 63 out.println("pageContext.getRequest().setAttribute(\"" + var + "\", " + value + ");"); 64 } 65 else if (scope.equals("session")) { 66 out.println("pageContext.getSession().setAttribute(\"" + var + "\", " + value + ");"); 67 } 68 else if (scope.equals("application")) { 69 out.println("pageContext.getServletContext().setAttribute(\"" + var + "\", " + value + ");"); 70 } 71 else 72 throw error(L.l("invalid scope `{0}'", scope)); 73 } 74 75 protected void generateSetOrRemove(JspJavaWriter out, 76 String var, String scope, 77 String value) 78 throws Exception 79 { 80 if (var == null) { 81 } 82 else if (scope == null) { 83 out.println("pageContext.defaultSetOrRemove(\"" + var + "\", " + value + ");"); 84 } 85 else if (scope.equals("page")) { 86 out.println("pageContext.pageSetOrRemove(\"" + var + "\", " + value + ");"); 87 } 88 else if (scope.equals("request")) { 89 out.println("pageContext.requestSetOrRemove(\"" + var + "\", " + value + ");"); 90 } 91 else if (scope.equals("session")) { 92 out.println("pageContext.sessionSetOrRemove(\"" + var + "\", " + value + ");"); 93 } 94 else if (scope.equals("application")) { 95 out.println("pageContext.applicationSetOrRemove(\"" + var + "\", " + value + ");"); 96 } 97 else 98 throw error(L.l("invalid scope `{0}'", scope)); 99 } 100 } 101 | Popular Tags |