diff --git a/TODO b/TODO new file mode 100644 index 0000000..366f62e --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +Block *.class \ No newline at end of file diff --git a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java index 3fb15aa..00fff9a 100755 --- a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java +++ b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java @@ -75,20 +75,11 @@ public class SimpleServletDispatcher extends HttpServlet /* E0 */'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', /* F0 */'o', 'n', 'o', 'o', 'o', 'o', 'o', '\u00F7', '-', 'u', 'u', 'u', 'u', 'y', '-', 'y' }; - /** - * - */ - @Override - public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException - { - doIt(request, response); - } - /** * * */ - public void doIt(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException + public void dispatch(final HttpServletRequest request, final HttpServletResponse response, final String webClassesRootPath) throws IOException, ServletException { logger.info("=================================================="); logger.info("getContextPath=[" + request.getContextPath() + "]"); @@ -141,7 +132,7 @@ public class SimpleServletDispatcher extends HttpServlet { // If file is not in WebContent root, search it in packaged // classes. - path = getServletContext().getRealPath("/") + "WEB-INF/classes/" + this.webclassesRootPath.replaceAll("\\.", "/") + request.getPathInfo(); + path = getServletContext().getRealPath("/") + "WEB-INF/classes/" + webClassesRootPath.replaceAll("\\.", "/") + request.getPathInfo(); } logger.debug("path2=" + path); @@ -150,7 +141,7 @@ public class SimpleServletDispatcher extends HttpServlet } else { - String className = pathInfoToClassName(path, this.webclassesRootPath); + String className = pathInfoToClassName(path, webClassesRootPath); logger.info("className=[" + className + "]"); HttpServlet servlet = instanciateServlet(className); @@ -176,7 +167,9 @@ public class SimpleServletDispatcher extends HttpServlet else { /* - * TODO // response.setContentType ("text/html"); PrintWriter + * TODO + * + * response.setContentType ("text/html"); PrintWriter * out = response.getWriter(); * * out.println (""); out.println @@ -186,13 +179,30 @@ public class SimpleServletDispatcher extends HttpServlet } } + /** + * + */ + @Override + public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException + { + dispatch(request, response, this.webclassesRootPath); + } + + /** + * Backward compatibility. + */ + public void doIt(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException + { + dispatch(request, response, this.webclassesRootPath); + } + /** * */ @Override public void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - doIt(request, response); + dispatch(request, response, this.webclassesRootPath); } /** @@ -307,14 +317,13 @@ public class SimpleServletDispatcher extends HttpServlet * Convert a path in a class name, using easy conventions. * *
-	 * "/" 
-	 * => "Index_xhtml" "/good/"
-	 * => "good.Good_xhtml" "/good/morning.xhtml"
-	 * => "good.Morning_xhtml" "/good/morning_girl.xhtml"
-	 * => "good.Morning_girl_xhtml" "/good/morning-123.xhtml"
-	 * => "good.Morning_xhtml" ('123' is detected as a parameter, it will be
-	 * decoded in the class called later). "/good/morning-/12/toto.jpg"
-	 * => "good.Morning" ('12' and 'toto.jpg" are detected as a parameter, they
+	 * "/" => "Index_xhtml"
+	 * "/good/" => "good.Good_xhtml"
+	 * "/good/morning.xhtml" => "good.Morning_xhtml"
+	 * "/good/morning_girl.xhtml" => "good.Morning_girl_xhtml"
+	 * "/good/morning-123.xhtml" => "good.Morning_xhtml" ('123' is detected as a parameter, it will be
+	 * decoded in the class called later).
+	 * "/good/morning-/12/toto.jpg" => "good.Morning" ('12' and 'toto.jpg" are detected as a parameter, they
 	 * will be decoded in the class called later).
 	 * 
*