This patches fixes Bug 2917.  The name of the .java files generated by Jasper
includes the path name, which can be a problem in Windows if the path name
is long.  Since the files are placed under the directories indicated by the
path name, there is really no reason to include the pathname with the file
name.

This fix is based on a submitter's ([EMAIL PROTECTED]) suggestion.

runsocks cvs diff -u JspCompiler.java
Index: JspCompiler.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/J
spCompiler.java,v
retrieving revision 1.6
diff -u -r1.6 JspCompiler.java
--- JspCompiler.java    2001/05/16 06:02:48     1.6
+++ JspCompiler.java    2001/09/07 21:24:48
@@ -123,40 +123,14 @@
     }
 
     private final String getBaseClassName() {
-       String className;
-        
+       // Only keep the file name, not the path.
+       int iSep = jsp.lastIndexOf(File.separatorChar) + 1;
+               // By luck, also works when '/' is absent
+       int iEnd = jsp.length();
         if (jsp.endsWith(".jsp"))
-            className = jsp.substring(0, jsp.length() - 4);
-        else
-            className = jsp;
+           iEnd = iEnd - 4;
             
-
-       // Fix for invalid characters. If you think of more add to the list.
-       StringBuffer modifiedClassName = new StringBuffer();
-       for (int i = 0; i < className.length(); i++) {
-           if (Character.isLetterOrDigit(className.charAt(i)) == true)
-               modifiedClassName.append(className.substring(i,i+1));
-           else
-               modifiedClassName.append(mangleChar(className.charAt(i)));
-       }
-       modifiedClassName.append("_jsp");
-       return modifiedClassName.toString();
-    }
-
-    private static final String mangleChar(char ch) {
-
-        if(ch == File.separatorChar) {
-           ch = '/';
-       }
-       String s = Integer.toHexString(ch);
-       int nzeros = 5 - s.length();
-       char[] result = new char[6];
-       result[0] = '_';
-       for (int i = 1; i <= nzeros; i++)
-           result[i] = '0';
-       for (int i = nzeros+1, j = 0; i < 6; i++, j++)
-           result[i] = s.charAt(j);
-       return new String(result);
+       return (jsp.substring(iSep, iEnd) + "_jsp");
     }
 
     /**

Reply via email to