diff options
-rw-r--r-- | src/org/traccar/Context.java | 2 | ||||
-rw-r--r-- | src/org/traccar/database/DataManager.java | 4 | ||||
-rw-r--r-- | src/org/traccar/web/WebServer.java | 16 |
3 files changed, 10 insertions, 12 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 2607fd107..ca2091148 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -406,7 +406,7 @@ public final class Context { } if (config.getBoolean("web.enable")) { - webServer = new WebServer(config, dataManager.getDataSource()); + webServer = new WebServer(config); } permissionsManager = new PermissionsManager(dataManager, usersManager); diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index f28041fc3..c3a53f4b6 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -91,10 +91,6 @@ public class DataManager { initDatabaseSchema(); } - public DataSource getDataSource() { - return dataSource; - } - private void initDatabase() throws Exception { String jndiName = config.getString("database.jndi"); diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 1f56c4139..82a119255 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -117,18 +117,20 @@ public class WebServer { } private void initWebApp() { - ResourceHandler resourceHandler = new ResourceHandler(); - resourceHandler.setResourceBase(config.getString("web.path")); + ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); + ServletHolder servletHolder = new ServletHolder(DefaultServlet.class); + servletHolder.setInitParameter("resourceBase", config.getString("web.path")); if (config.getBoolean("web.debug")) { - resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"}); + servletHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"}); } else { String cache = config.getString("web.cacheControl"); if (cache != null && !cache.isEmpty()) { - resourceHandler.setCacheControl(cache); + servletHolder.setInitParameter("cacheControl", cache); } - resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"}); + servletHandler.setWelcomeFiles(new String[] {"release.html", "index.html"}); } - handlers.addHandler(resourceHandler); + servletHandler.addServlet(servletHolder, "/*"); + handlers.addHandler(servletHandler); } private void initApi() { @@ -141,7 +143,7 @@ public class WebServer { servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket"); if (config.hasKey("media.path")) { - ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class); + ServletHolder servletHolder = new ServletHolder(DefaultServlet.class); servletHolder.setInitParameter("resourceBase", config.getString("media.path")); servletHolder.setInitParameter("dirAllowed", config.getString("media.dirAllowed", "false")); servletHolder.setInitParameter("pathInfoOnly", "true"); |