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:18:31 UTC

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

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();