1 28 29 package com.caucho.jsp.java; 30 31 import com.caucho.jsp.JspParseException; 32 import com.caucho.vfs.WriteStream; 33 34 import java.io.IOException ; 35 36 39 public class JspExpression extends JspNode { 40 private String _text; 41 42 45 public JspNode addText(String text) 46 { 47 _text = text; 48 49 return null; 50 } 51 52 55 public void endElement() 56 throws JspParseException 57 { 58 if (_parseState.isScriptingInvalid()) 59 throw error(L.l("Script expressions are forbidden here. Scripting has been disabled either:\n1) disabled by the web.xml scripting-invalid\n2) disabled in a tag's descriptor\n3) forbidden in <jsp:attribute> or <jsp:body> tags.")); 60 } 61 62 65 public boolean hasScripting() 66 { 67 return true; 68 } 69 70 75 public void printXml(WriteStream os) 76 throws IOException 77 { 78 os.print("<jsp:expression"); 79 printJspId(os); 80 os.print(">"); 81 82 printXmlText(os, _text); 83 os.print("</jsp:expression>"); 84 } 85 86 91 public void generate(JspJavaWriter out) 92 throws Exception 93 { 94 int length = _text.length(); 95 96 out.print("out.print(("); 97 98 boolean hasSlashes = false; 101 102 for (int i = 0; i < length; i++) { 103 char ch = _text.charAt(i); 104 105 if (ch == '/' && i + 1 < length && _text.charAt(i + 1) == '/') 106 hasSlashes = true; 107 108 if (ch == '\n') { 110 hasSlashes = false; 111 out.println(); 112 } 113 else 114 out.print(ch); 115 } 116 if (hasSlashes) 117 out.println(); 118 119 out.setLocation(_filename, _endLine); 121 123 out.println("));"); 124 } 125 } 126 | Popular Tags |