remm 2003/06/25 13:01:18 Modified: jasper2/src/share/org/apache/jasper JspC.java Log: - Cleanup (a bit) the insertion code so that it respects the order of elements of the 2.3 DTD (otherwise, the validator task refuses to validate the application ...). Revision Changes Path 1.45 +32 -14 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- JspC.java 1 May 2003 23:38:30 -0000 1.44 +++ JspC.java 25 Jun 2003 20:01:18 -0000 1.45 @@ -152,6 +152,13 @@ private static final int DEFAULT_DIE_LEVEL = 1; private static final int NO_DIE_LEVEL = 0; + private static final String[] insertBefore = + { "</web-app>", "<servlet-mapping>", "<session-config>", + "<mime-mapping>", "<welcome-file-list>", "<error-page>", "<taglib>", + "<resource-env-ref>", "<resource-ref>", "<security-constraint>", + "<login-config>", "<security-role>", "<env-entry>", "<ejb-ref>", + "<ejb-local-ref>" }; + private static int die; private String classPath = null; private URLClassLoader loader = null; @@ -552,33 +559,44 @@ new BufferedReader(new FileReader(webxmlFile)); PrintWriter writer = new PrintWriter(new FileWriter(webXml2)); - // TODO: This is a hack + // Insert the <servlet> and <servlet-mapping> declarations + int pos = -1; + String line = null; while (true) { - String line = reader.readLine(); + line = reader.readLine(); if (line == null) { break; } - int pos = line.indexOf("</web-app>"); + for (int i = 0; i < insertBefore.length; i++) { + pos = line.indexOf(insertBefore[i]); + if (pos >= 0) + break; + } if (pos >= 0) { writer.println(line.substring(0, pos)); break; } else { - writer.write(line); - writer.write("\n"); + writer.println(line); } } while (true) { - String line = fragmentReader.readLine(); - if (line == null) { + String line2 = fragmentReader.readLine(); + if (line2 == null) { break; } - writer.write(line); - writer.write("\n"); + writer.println(line2); } - writer.write("</web-app>"); - writer.write("\n"); + writer.println(line.substring(pos)); + + while (true) { + line = reader.readLine(); + if (line == null) { + break; + } + writer.println(line); + } writer.close(); reader.close();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]