You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by yury <yu...@sun.com> on 2000/03/14 20:15:10 UTC

[PATCH] Add extra info to the comments of the generated servlet

This patch adds extra information into the comments of the generated servlet
to improve
the JSP <----> servlet source line mapping.

The new info is the type of the generated code block (derived from the class
name
of the appropriate Generator).

Index: jasper/compiler/JakartaCommentGenerator.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JakartaC
ommentGenerator.java,v
retrieving revision 1.1
diff -u -r1.1 JakartaCommentGenerator.java
--- jasper/compiler/JakartaCommentGenerator.java	2000/02/25 19:45:38	1.1
+++ jasper/compiler/JakartaCommentGenerator.java	2000/03/08 22:05:18
@@ -83,6 +83,20 @@
  * @author Mandar Raje [patch submitted by Yury Kamen]
  */
 public class JakartaCommentGenerator implements CommentGenerator {
+     static private final String suffix   = "Generator";
// NOI18N
+     static private final String compiler = "org.apache.jasper.compiler.";
// NOI18N
+
+    private String getType(Generator generator) {
+        String type = generator.getClass().getName();
+        if ( type.startsWith(compiler)) {
+            type = type.substring(compiler.length());
+        }
+        int index = type.lastIndexOf(suffix);
+        if (index > 0) {
+             type = type.substring(0, index);
+        }
+	return type;
+    }

     /**
      * Generates "start-of the JSP-embedded code block" comment
@@ -93,7 +107,6 @@
      * @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 ";
@@ -101,12 +114,12 @@
  	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() + "]");
+		out.println(html + "// begin [file=" + fileName+";from=" +
start.toShortString() + ";to=" + stop.toShortString() + "] " +
getType(generator));
 	    } else {
-		out.println(html + "// begin [from="+start+";to="+stop+"]");
+		out.println(html + "// begin [from="+start+";to="+stop+"] " +
getType(generator));
             }
 	} else {
-	    out.println(html + "// begin");
+	    out.println(html + "// begin " + getType(generator));
         }

       out.pushIndent();
@@ -125,17 +138,3 @@
         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+"]");




[PATCH] fixes shutdown null ptr exception

Posted by Robin Meade <rm...@outreach.hawaii.edu>.
Hi,
I'm getting a null pointer exception when I execute shutdown.bat
because variable configFile is null.
(Anybody else getting this exception?)
This diff file shows how I fixed it:

===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v
retrieving revision 1.17
diff -r1.17 Tomcat.java
107,125c107,110
< 	File f;
< 
< 	// - if no -f config is specified, use tomcat.home and set
ContextManager.home to the same thing.
< 	//   The user probably wants the default tomcat.
< 	// - if a config file is specified - just use it, it will probably set the
contextmanager home.
< 	if( configFile==null ) {
< 	    String tchome=System.getProperty("tomcat.home");
< 	    if( tchome == null ) {
< 		System.out.println("No tomcat.home property, you need to set TOMCAT_HOME
or add -Dtomcat.home ");
< 		// try "." - a better solution would be to just exit.
< 		tchome=".";
< 	    } 
< 	    // Home will be identical to tomcat home if default config is used.
< 	    cm.setHome( tchome );
< 	    f=new File(tchome, DEFAULT_CONFIG );
< 	} else {
< 	    // config file is relative to the working directory
< 	    // if it doesn't set a home for the context manager, tomcat.home will
be used
< 	    f=new File(configFile);
---
> 	if (configFile == null) {
> 	    // - if no -f config is specified, set ContextManager.home to tomcat.home.
> 	    //   The user probably wants the default tomcat.
> 	    cm.setHome(getTomcatHome());
126a112,113
> 	
> 	File f = getConfigFile();
145a133,154
>     String getTomcatHome() {
>     	String tchome=System.getProperty("tomcat.home");
>     	if( tchome == null ) {
> 	    System.out.println("No tomcat.home property, you need to set TOMCAT_HOME or add -Dtomcat.home ");
> 	    // try "." - a better solution would be to just exit.
> 	    tchome=".";
>     	} 
>     	return tchome;
>     }
>     
>     File getConfigFile() {
> 	// - if no -f config is specified, use tomcat's default and set ContextManager.home to tomcat.home.
> 	//   The user probably wants the default tomcat.
> 	// - if a config file is specified - just use it, it will probably set the contextmanager home.
> 	if( configFile==null ) {
> 	    return new File(getTomcatHome(), DEFAULT_CONFIG );
> 	} else {
> 	    // config file is relative to the working directory
> 	    return new File(configFile);
> 	}
>     }
>     
172c181,187
< 	File f=new File(cm.getHome(), configFile);
---
> 	if (configFile == null) {
> 	    // - if no -f config is specified, set ContextManager.home to tomcat.home.
> 	    //   The user probably wants the default tomcat.
> 	    cm.setHome(getTomcatHome());
> 	}
> 	
> 	File f = getConfigFile(getTomcatHome());

======================================================================

[PATCH] Strip URI base prefix from the file name in org/apache/jasper/JspC.java

Posted by yury <yu...@sun.com>.
This patch strips the uri base prefix from the Jsp file name command line
argument
whenever possible. It fixes a problem of JspC supplying the parser with the
wrong file name.


Index: jasper/JspC.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/JspC.java,v
retrieving revision 1.8
diff -u -r1.8 JspC.java
--- jasper/JspC.java	2000/03/07 00:03:27	1.8
+++ jasper/JspC.java	2000/03/08 22:05:18
@@ -426,6 +426,8 @@


         String file = nextFile();
+
+	//System.err.println("file=" + file);
         while (file != null) {
             if (SWITCH_FILE_WEBAPP.equals(file)) {
                 String base = nextFile();
@@ -536,6 +538,28 @@
                     }
                 }
             } else {
+                File froot = new File(uriRoot);
+                String ubase = null;
+                try {
+                    ubase = froot.getCanonicalPath();
+                } catch (IOException ioe) {
+                    // if we cannot get the base, leave it null
+                };
+                //System.out.println("==" + ubase);
+
+                try {
+                  if (ubase != null) {
+                      File fjsp = new File(file);
+                      String s = fjsp.getCanonicalPath();
+                      //System.out.println("**" + s);
+                      if (s.startsWith(ubase)) {
+                           file = s.substring(ubase.length());
+                       };
+                   }
+                   file = file;
+                 } catch (IOException ioe) {
+                      // if we got problems dont change the file name
+                 };
                 parseFile(log, file, null);
             };
             file = nextFile();