tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/jasper/runtime JspServlet.java
Date Sun, 24 Oct 1999 00:30:10 GMT
akv         99/10/23 17:30:10

  Modified:    src/share/org/apache/jasper/compiler Tag:
                        TOMCAT_J2EE_10F_102199 Parser.java
               src/share/org/apache/jasper/runtime Tag:
                        TOMCAT_J2EE_10F_102199 JspServlet.java
  Log:
  Only expressions are accepted in HTML comments.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.1   +77 -36    jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- Parser.java	1999/10/21 07:56:40	1.4
  +++ Parser.java	1999/10/24 00:30:07	1.4.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v
1.4 1999/10/21 07:56:40 akv Exp $
  - * $Revision: 1.4 $
  - * $Date: 1999/10/21 07:56:40 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v
1.4.2.1 1999/10/24 00:30:07 akv Exp $
  + * $Revision: 1.4.2.1 $
  + * $Date: 1999/10/24 00:30:07 $
    *
    * ====================================================================
    * 
  @@ -93,14 +93,6 @@
        */
       CharArrayWriter caw;
   
  -    /**
  -     * constants for escapes
  -     */
  -    private static String QUOTED_START_TAG = "<\\%";
  -    private static String QUOTED_END_TAG = "%\\>";
  -    private static String START_TAG = "<%";
  -    private static String END_TAG = "%>";
  -
       public interface Action {
           void execute() throws JasperException;
       }
  @@ -406,7 +398,30 @@
       static {
   	coreElements.addElement(new Comment());
       }
  +
  +    /*
  +     * HTML comments
  +     */
  +    static final class HtmlComment implements CoreElement {
  +        
  +        private static final String OPEN_COMMENT = "<!--";
  +        private static final String CLOSE_COMMENT = "-->";
  +        
  +        public boolean accept(ParseEventListener listener, JspReader reader, Parser parser)
  +            throws JasperException 
  +        {
  +            if (reader.matches(OPEN_COMMENT)) {
  +                parser.parse(CLOSE_COMMENT, new Class[] { Expression.class });
  +                return true;
  +            } 
  +            return false;
  +        }
  +    }
       
  +    static {
  +        coreElements.addElement(new HtmlComment());
  +    }
  +            
       /*
        * Scripting elements
        */
  @@ -909,33 +924,42 @@
        * Entities &apos; and &quote;
        */
       static final class QuoteEscape implements CoreElement {
  +        /**
  +         * constants for escapes
  +         */
  +        private static String QUOTED_START_TAG = "<\\%";
  +        private static String QUOTED_END_TAG = "%\\>";
  +        private static String START_TAG = "<%";
  +        private static String END_TAG = "%>";
  +
   	private static final String APOS = "&apos;";
   	private static final String QUOTE = "&quote;";
  +        
   	public boolean accept(ParseEventListener listener, JspReader reader, Parser parser) 
  -	throws JasperException 
  +            throws JasperException 
   	{
  -	try {
  -	    if (reader.matches(parser.QUOTED_START_TAG)) {
  -		reader.advance(parser.QUOTED_START_TAG.length());
  -		parser.caw.write(parser.START_TAG);
  -		parser.flushCharData();
  -		return true;
  -	    } else if (reader.matches(APOS)) {
  -		reader.advance(APOS.length());
  -		parser.caw.write("\'");
  -		parser.flushCharData();
  -		return true;
  -	    }
  -	    else if (reader.matches(QUOTE)) {
  -		reader.advance(QUOTE.length());
  -		parser.caw.write("\"");
  -		parser.flushCharData();
  -		return true;
  -	    }
  -	} catch (java.io.IOException ex) {
  -	    System.out.println (ex.getMessage());
  -	}
  -	return false;
  +            try {
  +                if (reader.matches(QUOTED_START_TAG)) {
  +                    reader.advance(QUOTED_START_TAG.length());
  +                    parser.caw.write(START_TAG);
  +                    parser.flushCharData();
  +                    return true;
  +                } else if (reader.matches(APOS)) {
  +                    reader.advance(APOS.length());
  +                    parser.caw.write("\'");
  +                    parser.flushCharData();
  +                    return true;
  +                }
  +                else if (reader.matches(QUOTE)) {
  +                    reader.advance(QUOTE.length());
  +                    parser.caw.write("\"");
  +                    parser.flushCharData();
  +                    return true;
  +                }
  +            } catch (java.io.IOException ex) {
  +                System.out.println (ex.getMessage());
  +            }
  +            return false;
   	}
       }
       
  @@ -953,12 +977,29 @@
       public void parse() throws JasperException {
           parse(null);
       }
  -    
  +
       public void parse(String until) throws JasperException {
  +        parse(until, null);
  +    }
  +    
  +    public void parse(String until, Class[] accept) throws JasperException {
   	while (reader.hasMoreInput()) {
               if (until != null && reader.matches(until)) 
                   return;
  -	    Enumeration e = coreElements.elements();
  +
  +	    Enumeration e = coreElements.elements(); 
  +
  +            if (accept != null) {
  +                Vector v = new Vector();
  +                while (e.hasMoreElements()) {
  +                    CoreElement c = (CoreElement) e.nextElement();
  +                    for(int i = 0; i < accept.length; i++)
  +                        if (c.getClass().equals(accept[i]))
  +                            v.addElement(c);
  +                }
  +                e = v.elements();
  +            }
  +
   	    boolean accepted = false;
   	    while (e.hasMoreElements()) {
   		CoreElement c = (CoreElement) e.nextElement();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.1   +6 -5      jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- JspServlet.java	1999/10/21 01:48:43	1.5
  +++ JspServlet.java	1999/10/24 00:30:09	1.5.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v
1.5 1999/10/21 01:48:43 akv Exp $
  - * $Revision: 1.5 $
  - * $Date: 1999/10/21 01:48:43 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v
1.5.2.1 1999/10/24 00:30:09 akv Exp $
  + * $Revision: 1.5.2.1 $
  + * $Date: 1999/10/24 00:30:09 $
    *
    * ====================================================================
    * 
  @@ -324,6 +324,8 @@
               else
                   jspUri = includeUri;
   
  +            boolean precompile = preCompile(request);
  +
               if (Constants.matchVerbosity(Constants.MED_VERBOSITY)) {
   		System.err.println("JspEngine --> "+jspUri);
                   System.err.println("\t     ServletPath: "+request.getServletPath());
  @@ -339,8 +341,7 @@
                       System.err.println("\t\t "+name+" = "+request.getParameter(name));
                   }
               }
  -
  -            serviceJspFile(request, response, jspUri, null, preCompile(request));
  +            serviceJspFile(request, response, jspUri, null, precompile);
   	    
   	} catch (RuntimeException e) {
   	    throw e;
  
  
  

Mime
View raw message