tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gábor" "Lipták" <gaborlip...@usa.net>
Subject cvs diff proposed fix for bugs 13 and 104
Date Sun, 02 Apr 2000 01:02:50 GMT
This implements recursive parser invocation needed to resolve the above.

Index: src/share/org/apache/jasper/compiler/BaseJspListener.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/BaseJspListener.java,v
retrieving revision 1.5
diff -u -r1.5 BaseJspListener.java
--- src/share/org/apache/jasper/compiler/BaseJspListener.java	2000/02/25
19:45:37	1.5
+++ src/share/org/apache/jasper/compiler/BaseJspListener.java	2000/04/03
00:00:00
@@ -92,6 +92,9 @@
     public void endPageProcessing() throws JasperException {
     }
     
+    public void generateAll(Class phase) throws JasperException {
+    }
+
     public void handleComment(Mark start, Mark stop) throws JasperException
{
 	throw new
JasperException(Constants.getString("jsp.error.not.impl.comments"));
     }
Index: src/share/org/apache/jasper/compiler/DelegatingListener.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/DelegatingListener.java,v
retrieving revision 1.5
diff -u -r1.5 DelegatingListener.java
--- src/share/org/apache/jasper/compiler/DelegatingListener.java	2000/02/25
19:45:38	1.5
+++ src/share/org/apache/jasper/compiler/DelegatingListener.java	2000/04/03
00:00:00
@@ -104,6 +104,10 @@
         delegate.endPageProcessing();
     }
     
+    public void generateAll(Class phase) throws JasperException {
+      delegate.generateAll(phase);
+    }
+
     public void handleComment(Mark start, Mark stop) throws JasperException
{
         doAction(this.tmplStart, this.tmplStop);
         delegate.handleComment(start, stop);
Index: src/share/org/apache/jasper/compiler/JspParseEventListener.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
retrieving revision 1.13
diff -u -r1.13 JspParseEventListener.java
--- src/share/org/apache/jasper/compiler/JspParseEventListener.java	2000/03/31
19:43:52	1.13
+++ src/share/org/apache/jasper/compiler/JspParseEventListener.java	2000/04/03
00:00:00
@@ -192,7 +192,7 @@
         ctxt.setContentType(servletContentType);
     }
 
-    private void generateAll(Class phase) throws JasperException {
+    public void generateAll(Class phase) throws JasperException {
 	
 	for(int i = 0; i < generators.size(); i++) {
             Generator gen = (Generator) generators.elementAt(i);
Index: src/share/org/apache/jasper/compiler/JspReader.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v
retrieving revision 1.13
diff -u -r1.13 JspReader.java
--- src/share/org/apache/jasper/compiler/JspReader.java	2000/03/28 04:29:48
1.13
+++ src/share/org/apache/jasper/compiler/JspReader.java	2000/04/03 00:00:00
@@ -219,10 +219,24 @@
 	pushFile(file, encoding);
     }
 
+    protected JspReader(char[] buffer, JspCompilationContext ctx, String
encoding) 
+	throws ParseException, FileNotFoundException
+    {
+        this.context = ctx;
+	int fileid=registerSourceFile(".inline");
+        current = new Mark(this, buffer, fileid, ".inline", encoding);
+    }
+
     public static JspReader createJspReader(String file,
JspCompilationContext ctx, String encoding) 
 	throws ParseException, FileNotFoundException
     {
 	return new JspReader(file, ctx, encoding);
+    }
+
+    public static JspReader createJspReader(char[] buffer,
JspCompilationContext ctx, String encoding) 
+	throws ParseException, FileNotFoundException
+    {
+	return new JspReader(buffer, ctx, encoding);
     }
 
     public boolean hasMoreInput() {
Index: src/share/org/apache/jasper/compiler/ParseEventListener.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/ParseEventListener.java,v
retrieving revision 1.5
diff -u -r1.5 ParseEventListener.java
--- src/share/org/apache/jasper/compiler/ParseEventListener.java	2000/02/25
19:45:38	1.5
+++ src/share/org/apache/jasper/compiler/ParseEventListener.java	2000/04/03
00:00:00
@@ -120,4 +120,5 @@
 	throws JasperException;
 
     void endPageProcessing() throws JasperException;
+    void generateAll(Class phase) throws JasperException;
 }
Index: src/share/org/apache/jasper/compiler/PluginGenerator.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/PluginGenerator.java,v
retrieving revision 1.3
diff -u -r1.3 PluginGenerator.java
--- src/share/org/apache/jasper/compiler/PluginGenerator.java	2000/01/24
05:54:51	1.3
+++ src/share/org/apache/jasper/compiler/PluginGenerator.java	2000/04/03
00:00:00
@@ -63,6 +63,7 @@
 
 import java.util.Hashtable;
 import java.util.Enumeration;
+import java.io.FileNotFoundException;
 
 import org.apache.jasper.JasperException;
 import org.apache.jasper.Constants;
@@ -82,8 +83,8 @@
     String fallback;
 
     String ieClassId;
+    JspCompilationContext ctxt;
     
-    
     public PluginGenerator(Hashtable attrs, Hashtable param, String fallback)
{
     	this.attrs = attrs;
 	this.param = param;
@@ -91,6 +92,7 @@
     }
 
     public void init(JspCompilationContext ctxt) throws JasperException {
+        this.ctxt=ctxt;
         ieClassId = ctxt.getOptions().getIeClassId();
     }
     
@@ -184,7 +186,7 @@
 	        key = (String) e.nextElement ();
 	        value = (String[]) param.get (key);
 	        writer.indent ();
-	        writer.print ("out.println (\"<PARAM name=\\\"");
+	        writer.print ("out.print(\"<PARAM name=\\\"");
 		if (key.equalsIgnoreCase ("object"))
 		    writer.print ("java_object");
 		else if (key.equalsIgnoreCase ("type"))
@@ -193,9 +195,15 @@
 	            writer.print (key);
 	        writer.print ("\\\"");
 	        writer.print (" value=\\\"");
-	        writer.print (value[0]);
+		if (value[0].indexOf("<")==-1){
+		  writer.print (value[0]);
+                } else {
+                  writer.println("\");");
+                  parseBuffer(writer, value[0].toCharArray());
+                  writer.print("out.print(\"");
+		}
 	        writer.print ("\\\"");
-	        writer.print (">\");");
+	        writer.print (">\"); out.println();");
 	        writer.println ();
 	    }
 	}
@@ -249,7 +257,13 @@
 		else 
 	            writer.print (key);
 	        writer.print ("=\\\"");
-	        writer.print (value[0]);
+		if (value[0].indexOf("<")==-1){
+		  writer.print (value[0]);
+                } else {
+                  writer.println("\");");
+                  parseBuffer(writer, value[0].toCharArray());
+                  writer.print("out.println(\"");
+		}
 	        writer.print ("\\\"");
 	        writer.print (" ");
 	    }
@@ -271,6 +285,26 @@
 	writer.println ("out.println (\"</NOEMBED></EMBED>\");");
 	writer.println ("out.println (\"</OBJECT>\");");
 	writer.pushIndent ();
+    }
+
+    protected void parseBuffer(ServletWriter writer, char[] buffer)
+            throws JasperException{
+        JspReader reader=null;
+        try {
+           reader = JspReader.createJspReader(
+              buffer,
+              ctxt,
+              ctxt.getContentType()
+           );
+        } catch(FileNotFoundException e) { 
+            /* no file is involved, safe to ignore */ 
+        }
+        ParseEventListener listener = new JspParseEventListener(ctxt);
+        
+        Parser p = new Parser(reader, listener);
+        listener.beginPageProcessing();
+        p.parse();
+	listener.generateAll(ServiceMethodPhase.class);
     }
 
     public void generateCommon (ServletWriter writer) {


____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message