1 29 30 package com.caucho.jsp.java; 31 32 import com.caucho.jsp.JspParseException; 33 import com.caucho.vfs.WriteStream; 34 35 import java.io.IOException ; 36 37 40 public class JspScriptlet extends JspNode { 41 private String _text; 42 43 46 public JspNode addText(String text) 47 { 48 if (_text == null) 49 _text = text; 50 else 51 _text += text; 52 53 return null; 54 } 55 56 59 public void endElement() 60 throws JspParseException 61 { 62 if (_parseState.isScriptingInvalid()) 63 throw error(L.l("Scriptlets 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.")); 64 } 65 66 69 public boolean hasScripting() 70 { 71 return true; 72 } 73 74 79 public void printXml(WriteStream os) 80 throws IOException 81 { 82 os.print("<jsp:scriptlet"); 83 printJspId(os); 84 os.print(">"); 85 86 printXmlText(os, _text); 87 os.print("</jsp:scriptlet>"); 88 } 89 90 95 public void generate(JspJavaWriter out) 96 throws Exception 97 { 98 int length = _text.length(); 99 100 for (int i = 0; i < length; i++) { 101 char ch = _text.charAt(i); 102 103 if (ch == '\r' && i + 1 < length && _text.charAt(i + 1) != '\n') 104 ch = '\n'; 105 106 out.print(ch); 107 } 108 109 out.setLocation(_filename, _endLine); 111 113 out.println(); 114 } 115 } 116 | Popular Tags |