Improve code organization.
This commit is contained in:
parent
d08172840b
commit
61168e5b32
2 changed files with 32 additions and 22 deletions
1
TODO
Normal file
1
TODO
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Block *.class
|
|
@ -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',
|
/* 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' };
|
/* 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("==================================================");
|
||||||
logger.info("getContextPath=[" + request.getContextPath() + "]");
|
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
|
// If file is not in WebContent root, search it in packaged
|
||||||
// classes.
|
// 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);
|
logger.debug("path2=" + path);
|
||||||
|
|
||||||
|
@ -150,7 +141,7 @@ public class SimpleServletDispatcher extends HttpServlet
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String className = pathInfoToClassName(path, this.webclassesRootPath);
|
String className = pathInfoToClassName(path, webClassesRootPath);
|
||||||
logger.info("className=[" + className + "]");
|
logger.info("className=[" + className + "]");
|
||||||
|
|
||||||
HttpServlet servlet = instanciateServlet(className);
|
HttpServlet servlet = instanciateServlet(className);
|
||||||
|
@ -176,7 +167,9 @@ public class SimpleServletDispatcher extends HttpServlet
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* TODO // response.setContentType ("text/html"); PrintWriter
|
* TODO
|
||||||
|
*
|
||||||
|
* response.setContentType ("text/html"); PrintWriter
|
||||||
* out = response.getWriter();
|
* out = response.getWriter();
|
||||||
*
|
*
|
||||||
* out.println ("<html><head></head><body>"); out.println
|
* out.println ("<html><head></head><body>"); 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
|
@Override
|
||||||
public void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
|
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.
|
* Convert a path in a class name, using easy conventions.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* "/"
|
* "/" => "Index_xhtml"
|
||||||
* => "Index_xhtml" "/good/"
|
* "/good/" => "good.Good_xhtml"
|
||||||
* => "good.Good_xhtml" "/good/morning.xhtml"
|
* "/good/morning.xhtml" => "good.Morning_xhtml"
|
||||||
* => "good.Morning_xhtml" "/good/morning_girl.xhtml"
|
* "/good/morning_girl.xhtml" => "good.Morning_girl_xhtml"
|
||||||
* => "good.Morning_girl_xhtml" "/good/morning-123.xhtml"
|
* "/good/morning-123.xhtml" => "good.Morning_xhtml" ('123' is detected as a parameter, it will be
|
||||||
* => "good.Morning_xhtml" ('123' is detected as a parameter, it will be
|
* decoded in the class called later).
|
||||||
* decoded in the class called later). "/good/morning-/12/toto.jpg"
|
* "/good/morning-/12/toto.jpg" => "good.Morning" ('12' and 'toto.jpg" are detected as a parameter, they
|
||||||
* => "good.Morning" ('12' and 'toto.jpg" are detected as a parameter, they
|
|
||||||
* will be decoded in the class called later).
|
* will be decoded in the class called later).
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue