You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@locus.apache.org on 2000/02/25 20:45:39 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/jasper/compiler CommentGenerator.java JakartaCommentGenerator.java BaseJspListener.java DelegatingListener.java JspParseEventListener.java ParseEventListener.java Parser.java

mandar      00/02/25 11:45:39

  Modified:    src/share/org/apache/jasper/compiler BaseJspListener.java
                        DelegatingListener.java JspParseEventListener.java
                        ParseEventListener.java Parser.java
  Added:       src/share/org/apache/jasper/compiler CommentGenerator.java
                        JakartaCommentGenerator.java
  Log:
  1) Generate line numbers for HTML (template) data in
     the generated servlet.
  2) Added flexibility of having a custom-comment generator.
  
  Revision  Changes    Path
  1.5       +7 -4      jakarta-tomcat/src/share/org/apache/jasper/compiler/BaseJspListener.java
  
  Index: BaseJspListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/BaseJspListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseJspListener.java	2000/02/23 02:23:44	1.4
  +++ BaseJspListener.java	2000/02/25 19:45:37	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/BaseJspListener.java,v 1.4 2000/02/23 02:23:44 mandar Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/02/23 02:23:44 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/BaseJspListener.java,v 1.5 2000/02/25 19:45:37 mandar Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/02/25 19:45:37 $
    *
    * ====================================================================
    * 
  @@ -83,6 +83,9 @@
   	this.writer = writer;
       }
   
  +    public void setTemplateInfo(Mark start, Mark stop) {
  +    }
  +
       public void beginPageProcessing() throws JasperException {
       }
       
  @@ -142,7 +145,7 @@
   	throw new JasperException(Constants.getString("jsp.error.not.impl.plugin"));
       }
       
  -    public void handleCharData(char[] chars) throws JasperException {
  +    public void handleCharData(Mark start, Mark stop, char[] chars) throws JasperException {
           System.err.print(chars);
       }
   
  
  
  
  1.5       +28 -21    jakarta-tomcat/src/share/org/apache/jasper/compiler/DelegatingListener.java
  
  Index: DelegatingListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/DelegatingListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DelegatingListener.java	2000/02/23 02:23:44	1.4
  +++ DelegatingListener.java	2000/02/25 19:45:38	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/DelegatingListener.java,v 1.4 2000/02/23 02:23:44 mandar Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/02/23 02:23:44 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/DelegatingListener.java,v 1.5 2000/02/25 19:45:38 mandar Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/02/25 19:45:38 $
    *
    * ====================================================================
    * 
  @@ -80,16 +80,22 @@
   final class DelegatingListener implements ParseEventListener {
       ParseEventListener delegate;
       Parser.Action action;
  +    Mark tmplStart, tmplStop;
       
       DelegatingListener(ParseEventListener delegate, Parser.Action action) {
           this.delegate = delegate;
           this.action = action;
       }
   
  -    void doAction() throws JasperException {
  -        action.execute();
  +    void doAction(Mark start, Mark stop) throws JasperException {
  +        action.execute(start, stop);
       }
   
  +    public void setTemplateInfo(Mark start, Mark stop) {
  +	this.tmplStart = start;
  +	this.tmplStop = stop;
  +    }
  +
       public void beginPageProcessing() throws JasperException {
           delegate.beginPageProcessing();
       }
  @@ -99,57 +105,57 @@
       }
       
       public void handleComment(Mark start, Mark stop) throws JasperException {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleComment(start, stop);
       }
   
       public void handleDirective(String directive, Mark start, Mark stop, Hashtable attrs) 
   	throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleDirective(directive, start, stop, attrs);
       }
       
       public void handleDeclaration(Mark start, Mark stop, Hashtable attrs) throws JasperException {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleDeclaration(start, stop, attrs);
       }
       
       public void handleScriptlet(Mark start, Mark stop, Hashtable attrs) throws JasperException {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleScriptlet(start, stop, attrs);
       }
       
       public void handleExpression(Mark start, Mark stop, Hashtable attrs) throws JasperException {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleExpression(start, stop, attrs);
       }
   
       public void handleBean(Mark start, Mark stop, Hashtable attrs) 
   	throws JasperException
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleBean(start, stop, attrs);
       }
       
       public void handleBeanEnd(Mark start, Mark stop, Hashtable attrs) 
   	throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleBeanEnd(start, stop, attrs);
       }
   
       public void handleGetProperty(Mark start, Mark stop, Hashtable attrs) 
   	throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleGetProperty(start, stop, attrs);
       }
       
       public void handleSetProperty(Mark start, Mark stop, Hashtable attrs) 
   	throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleSetProperty(start, stop, attrs);
       }
       
  @@ -157,25 +163,25 @@
       				Hashtable param, String fallback) 
           throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handlePlugin(start, stop, attrs, param, fallback);
       }
       
  -    public void handleCharData(char[] chars) throws JasperException {
  -        delegate.handleCharData(chars);
  +    public void handleCharData(Mark start, Mark stop, char[] chars) throws JasperException {
  +        delegate.handleCharData(start, stop, chars);
       }
   
       public void handleForward(Mark start, Mark stop, Hashtable attrs, Hashtable param) 
           throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleForward(start, stop, attrs, param);
       }
   
       public void handleInclude(Mark start, Mark stop, Hashtable attrs, Hashtable param) 
           throws JasperException 
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleInclude(start, stop, attrs, param);
       }
   
  @@ -184,7 +190,7 @@
   			       TagInfo ti)
   	throws JasperException
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleTagBegin(start, stop, attrs, prefix, shortTagName, tli, ti);
       }
       
  @@ -193,7 +199,7 @@
                                TagLibraryInfoImpl tli, TagInfo ti)
   	throws JasperException
       {
  -        doAction();
  +        doAction(this.tmplStart, this.tmplStop);
           delegate.handleTagEnd(start, stop, prefix, shortTagName, attrs, tli, ti);
       }
       
  @@ -201,3 +207,4 @@
           return delegate.getTagLibraries();
       }
   }
  +
  
  
  
  1.10      +33 -19    jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java
  
  Index: JspParseEventListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JspParseEventListener.java	2000/02/23 19:53:25	1.9
  +++ JspParseEventListener.java	2000/02/25 19:45:38	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v 1.9 2000/02/23 19:53:25 rubys Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/02/23 19:53:25 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v 1.10 2000/02/25 19:45:38 mandar Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/02/25 19:45:38 $
    *
    * ====================================================================
    * 
  @@ -89,6 +89,8 @@
    */
   public class JspParseEventListener extends BaseJspListener {
   
  +    private static CommentGenerator commentGenerator = new JakartaCommentGenerator();    
  +
       JspCompilationContext ctxt;
       
       String jspServletBase = Constants.JSP_SERVLET_BASE;
  @@ -130,6 +132,14 @@
           gen.init(ctxt);
           generators.addElement(gen);
       }
  +
  +    public static void setCommentGenerator(CommentGenerator generator) {
  +	if ( null == commentGenerator) {
  +	    throw new IllegalArgumentException("null == generator");
  +	}
  +
  +	commentGenerator = generator;
  +    }    
       
       /*
        * Package private since I want everyone to come in through 
  @@ -707,23 +717,27 @@
               if (phase.isInstance(generator)) {
                   boolean genCoords = generator.generateCoordinates(phase);
                   if (genCoords) {
  -                    if (start != null && stop != null) {
  -                        if (start.fileid == stop.fileid) {
  -			    String fileName = out.quoteString(
  -			    				start.getFile ());
  -                            out.println("// begin [file="+fileName+";from="+
  -                                        start.toShortString()+";to="+stop.toShortString()+"]");
  -			}
  -                        else
  -                            out.println("// begin [from="+start+";to="+stop+"]");
  -                    } else
  -                        out.println("// begin");
  -                    out.pushIndent();
  +		    commentGenerator.generateStartComment
  +			(generator, out, start, stop);
  +                    //if (start != null && stop != null) {
  +		    //  if (start.fileid == stop.fileid) {
  +		    //    String fileName = out.quoteString(
  +		    //    				start.getFile ());
  +		    //      out.println("// begin [file="+fileName+";from="+
  +		    //                  start.toShortString()+";to="+stop.toShortString()+"]");
  +		    //}
  +		    //  else
  +		    //      out.println("// begin [from="+start+";to="+stop+"]");
  +                    //} else
  +		    //  out.println("// begin");
  +                    //out.pushIndent();
                   }
                   generator.generate(out, phase);
                   if (genCoords) {
  -                    out.popIndent();
  -                    out.println("// end");
  +		    commentGenerator.generateEndComment
  +			(generator, out, start, stop);
  +                    //out.popIndent();
  +                    //out.println("// end");
                   }
               }
           }
  @@ -831,7 +845,7 @@
       }
       
       
  -    public void handleCharData(char[] chars) throws JasperException {
  +    public void handleCharData(Mark start, Mark stop, char[] chars) throws JasperException {
           GeneratorBase cdg;
   
           if (ctxt.getOptions().getLargeFile())
  @@ -845,7 +859,7 @@
           // FIXME: change null
           Generator gen
               = new GeneratorWrapper(cdg,
  -                                   null, null);
  +                                   start, stop);
   	
   	addGenerator(gen);
       }
  
  
  
  1.5       +5 -4      jakarta-tomcat/src/share/org/apache/jasper/compiler/ParseEventListener.java
  
  Index: ParseEventListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ParseEventListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParseEventListener.java	2000/02/23 02:23:44	1.4
  +++ ParseEventListener.java	2000/02/25 19:45:38	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ParseEventListener.java,v 1.4 2000/02/23 02:23:44 mandar Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/02/23 02:23:44 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/ParseEventListener.java,v 1.5 2000/02/25 19:45:38 mandar Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/02/25 19:45:38 $
    *
    * ====================================================================
    * 
  @@ -75,6 +75,7 @@
    * @author Anil K. Vijendran
    */
   public interface ParseEventListener {
  +    void setTemplateInfo(Mark start, Mark stop);
       void beginPageProcessing() throws JasperException;
   
       void handleComment(Mark start, Mark stop) throws JasperException;
  @@ -92,7 +93,7 @@
       void handleSetProperty(Mark start, Mark stop, Hashtable attrs) throws JasperException;
       void handlePlugin(Mark start, Mark stop, Hashtable attrs, Hashtable param, 
       			String fallback) throws JasperException;
  -    void handleCharData(char[] chars) throws JasperException;
  +    void handleCharData(Mark start, Mark stop, char[] chars) throws JasperException;
   
   
       /*
  
  
  
  1.16      +49 -12    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Parser.java	2000/02/23 02:23:45	1.15
  +++ Parser.java	2000/02/25 19:45:38	1.16
  @@ -90,18 +90,24 @@
        */
       CharArrayWriter caw;
   
  +    /*
  +     * Marker for start and end of the tempate data.
  +     */
  +    Mark tmplStart;
  +    Mark tmplStop;
  +
       public interface Action {
  -        void execute() throws JasperException;
  +        void execute(Mark start, Mark stop) throws JasperException;
       }
   
       public Parser(JspReader reader, final ParseEventListener lnr) {
   	this.reader = reader;
   	this.listener = new DelegatingListener(lnr,
                                                  new Action() {
  -                                                       public void execute() 
  +                                                       public void execute(Mark start, Mark stop) 
                                                              throws JasperException 
                                                          {
  -                                                           Parser.this.flushCharData();
  +                                                           Parser.this.flushCharData(start, stop);
                                                          }
                                                      });
   	this.caw = new CharArrayWriter();
  @@ -196,7 +202,8 @@
   		reader.advance(close.length());
   
   	    Mark stop = reader.mark();
  -	    
  +
  +	    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);
   	    listener.handleDirective(match, start, stop, attrs);
   	    return true;
   	}
  @@ -280,6 +287,7 @@
   		else
   		    reader.advance(CLOSE_INCLUDE_NO_BODY.length());
   		Mark stop = reader.mark();
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handleInclude(start, stop, attrs, param);
   		return true;
   	    } else
  @@ -361,6 +369,7 @@
   		    reader.advance(CLOSE_FORWARD_NO_BODY.length());
   		
   		Mark stop = reader.mark();
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handleForward(start, stop, attrs, param);
   		return true;
   	    } else
  @@ -395,7 +404,7 @@
   		    throw new ParseException(Constants.getString("jsp.error.unterminated", 
                                                                    new Object[] { OPEN_COMMENT }));
   		
  -		parser.flushCharData();
  +		parser.flushCharData(start, stop);
   		return true;
   	    }
   	    return false;
  @@ -452,6 +461,7 @@
   		throw new ParseException(Constants.getString("jsp.error.unterminated", 
                                                                new Object[] { open }));
   
  +	    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);	    
   	    listener.handleDeclaration(start, stop, attrs);
   	    return true;
   	}
  @@ -504,6 +514,7 @@
   		throw new ParseException(reader.mark(), 
                                            Constants.getString("jsp.error.unterminated", 
                                                                    new Object[] { open }));
  +	    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);	    
   	    listener.handleExpression(start, stop, attrs);
   	    return true;
   	}
  @@ -555,6 +566,7 @@
   		throw new ParseException(reader.mark(), 
                                            Constants.getString("jsp.error.unterminated", 
                                                                    new Object[] { open }));
  +	    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);	    
   	    listener.handleScriptlet(start, stop, attrs);
   	    return true;
   	}
  @@ -598,6 +610,7 @@
                                                                    new Object[] { "useBean" }));
   		    reader.advance(CLOSE_BEAN_3.length());
                       Mark stop = reader.mark();
  +		    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		    
                       listener.handleBean(start, stop, attrs);
   		    int oldSize = reader.size;
   		    parser.parse(CLOSE_BEAN_2);
  @@ -613,11 +626,13 @@
   						 );
   
   		    reader.advance (CLOSE_BEAN_2.length());
  +		    
                       listener.handleBeanEnd(start, stop, attrs);
                       return true;
   		} else {
                       reader.advance(CLOSE_BEAN.length());
                       Mark stop = reader.mark();
  +		    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		    
                       listener.handleBean(start, stop, attrs);
                       listener.handleBeanEnd(start, stop, attrs);
                       return true;
  @@ -660,6 +675,7 @@
   		else
   		    reader.advance(CLOSE_GETPROPERTY.length());
   		Mark stop = reader.mark();
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handleGetProperty(start, stop, attrs);
   		return true;
   	    } else
  @@ -702,6 +718,7 @@
   		else
   		    reader.advance(CLOSE_SETPROPERTY.length());
   		Mark stop = reader.mark();
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handleSetProperty(start, stop, attrs);
   		return true;
   	    } else
  @@ -781,7 +798,8 @@
   		    reader.advance(CLOSE_1.length());
   		else
   		    throw new ParseException(start, "Body is supposed to be empty for "+tag);
  -		
  +
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handleTagBegin(start, reader.mark(), attrs, prefix,
   					shortTagName, tli, ti);
   		listener.handleTagEnd(start, reader.mark(), prefix, 
  @@ -793,6 +811,7 @@
   		if (reader.matches(CLOSE)) {
   		    reader.advance(CLOSE.length());
   		    bodyStart = reader.mark();
  +		    listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		    
   		    listener.handleTagBegin(start, bodyStart, attrs, prefix, 
   					    shortTagName, tli, ti);
                       if (bc.equalsIgnoreCase(TagInfo.BODY_CONTENT_TAG_DEPENDENT) ||
  @@ -932,6 +951,7 @@
   
   		reader.advance(CLOSE_PLUGIN.length());
   		Mark stop = reader.mark();
  +		listener.setTemplateInfo(parser.tmplStart, parser.tmplStop);		
   		listener.handlePlugin(start, stop, attrs, param, fallback);
   		return true;
   	    } else
  @@ -963,21 +983,25 @@
               throws JasperException 
   	{
               try {
  +		Mark start = reader.mark();
                   if (reader.matches(QUOTED_START_TAG)) {
                       reader.advance(QUOTED_START_TAG.length());
  +		    Mark end = reader.mark();
                       parser.caw.write(START_TAG);
  -                    parser.flushCharData();
  +                    parser.flushCharData(start, end);
                       return true;
                   } else if (reader.matches(APOS)) {
                       reader.advance(APOS.length());
  +		    Mark end = reader.mark();
                       parser.caw.write("\'");
  -                    parser.flushCharData();
  +                    parser.flushCharData(start, end);
                       return true;
                   }
                   else if (reader.matches(QUOTE)) {
                       reader.advance(QUOTE.length());
  +		    Mark end = reader.mark();
                       parser.caw.write("\"");
  -                    parser.flushCharData();
  +                    parser.flushCharData(start, end);
                       return true;
                   }
               } catch (java.io.IOException ex) {
  @@ -991,10 +1015,10 @@
   	coreElements.addElement(new QuoteEscape());
       }
   
  -    void flushCharData() throws JasperException {
  +    void flushCharData(Mark start, Mark stop) throws JasperException {
           char[] array = caw.toCharArray();
           if (array.length != 0) // Avoid unnecessary out.write("") statements...
  -            listener.handleCharData(caw.toCharArray());
  +            listener.handleCharData(start, stop, caw.toCharArray());
           caw = new CharArrayWriter();
       }
   
  @@ -1007,6 +1031,8 @@
       }
       
       public void parse(String until, Class[] accept) throws JasperException {
  +
  +	boolean noJspElement = false;
   	while (reader.hasMoreInput()) {
               if (until != null && reader.matches(until)) 
                   return;
  @@ -1033,14 +1059,25 @@
                                         new Object[] { c.getClass().getName(), m },
                                         Logger.DEBUG);
   		    accepted = true;
  +		    noJspElement = false;
   		    break;
   		} 
   	    }
   	    if (!accepted) {
  +
  +		// This is a hack. "reader.nextContent()" will just return 
  +		// after it sees "<" -- not necessarily a JSP element. Using
  +		// a boolean we will ensure that tmplStart changes only when
  +		// strictly necessary.
  +		if (noJspElement == false) {
  +		    tmplStart = reader.mark();
  +		    noJspElement = true;
  +		}
   		String s = reader.nextContent();
  +		tmplStop = reader.mark();
   		caw.write(s, 0, s.length());
   	    }
   	}
  -	flushCharData();
  +	flushCharData(tmplStart, tmplStop);
       }
   }
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/jasper/compiler/CommentGenerator.java
  
  Index: CommentGenerator.java
  ===================================================================
  /*
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.jasper.compiler;
  
  import java.util.Hashtable;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.util.StringTokenizer;
  import java.io.IOException;
  import java.io.FileNotFoundException;
  import java.io.File;
  import java.io.ObjectOutputStream;
  import java.io.FileOutputStream;
  import java.net.URL;
  import java.net.MalformedURLException;
  
  import javax.servlet.jsp.tagext.TagInfo;
  import javax.servlet.jsp.tagext.TagLibraryInfo;
  
  import org.apache.jasper.JasperException;
  import org.apache.jasper.Constants;
  import org.apache.jasper.JspCompilationContext;
  
  public interface CommentGenerator {
      
      /**
       * Generates "start-of the JSP-embedded code block" comment
       *
       * @param out The ServletWriter
       * @param start Start position of the block
       * @param stop End position of the block
       * @exception JasperException
       *
       * @author Mandar Raje [Patch submitted by Yury Kamen]
       */
      void generateStartComment(Generator generator, ServletWriter out, Mark start, Mark stop) throws JasperException;
  
      /**
       * Generates "end-of the JSP-embedded code block" comment
       *
       * @param out The ServletWriter
       * @param start Start position of the block
       * @param stop End position of the block
       * @exception JasperException 
       */
      void generateEndComment(Generator generator, ServletWriter out, Mark start, Mark stop) throws JasperException;
  }
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/jasper/compiler/JakartaCommentGenerator.java
  
  Index: JakartaCommentGenerator.java
  ===================================================================
  /*
   *
   * ====================================================================
   * 
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package org.apache.jasper.compiler;
  
  import java.util.Hashtable;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.util.StringTokenizer;
  import java.io.IOException;
  import java.io.FileNotFoundException;
  import java.io.File;
  import java.io.ObjectOutputStream;
  import java.io.FileOutputStream;
  import java.net.URL;
  import java.net.MalformedURLException;
  
  import javax.servlet.jsp.tagext.TagInfo;
  import javax.servlet.jsp.tagext.TagLibraryInfo;
  
  import org.apache.jasper.JasperException;
  import org.apache.jasper.Constants;
  import org.apache.jasper.JspCompilationContext;
  
  /**
   * Generates original "Jakarta"-style comments
   *
   * @author Mandar Raje [patch submitted by Yury Kamen]
   */
  public class JakartaCommentGenerator implements CommentGenerator {
      
      /**
       * Generates "start-of the JSP-embedded code block" comment
       *
       * @param out The ServletWriter
       * @param start Start position of the block
       * @param stop End position of the block
       * @exception JasperException 
       */
      public void generateStartComment(Generator generator, ServletWriter out, Mark start, Mark stop) throws JasperException {
          //System.err.println(generator.getClass().getName());
  	String html = "";
          if (generator instanceof CharDataGenerator) {
  	   html = "// HTML ";
  	}
   	if (start != null && stop != null) {
  	    if (start.fileid == stop.fileid) {
  		String fileName = out.quoteString(start.getFile ());
  		out.println(html + "// begin [file=" + fileName+";from=" + start.toShortString() + ";to=" + stop.toShortString() + "]");
  	    } else {
  		out.println(html + "// begin [from="+start+";to="+stop+"]");
              }
  	} else {
  	    out.println(html + "// begin");
          }
  
        out.pushIndent();
      }
  
     /**
       * Generates "end-of the JSP-embedded code block" comment
       *
       * @param out The ServletWriter
       * @param start Start position of the block
       * @param stop End position of the block
       * @exception JasperException
       */
      public void generateEndComment(Generator generator, ServletWriter out, Mark start, Mark stop) throws JasperException {
  	out.popIndent();
          out.println("// end");
      }
  }
  //        String fileName = "null";
  //         if(start != null) {
  //              fileName = out.quoteString(start.getFile());
  //         }
  //         String startString = "null";
  //         if(null != start) {
  //            startString =  start.toShortString();
  //         }
  
  //         String stopString = "null";
  //         if(null != stop) {
  //            stopString =  stop.toShortString();
  //         }
  //         out.println("// begin [file="+fileName+";from="+startString+";to="+stopString+"]");