aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/WebServer.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-30 11:40:45 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-30 11:40:45 +1300
commitf8e2c913fd18c40025cc110cd7c4506b6038b123 (patch)
tree73b1f1cb44aa9cf711c8111a84c5dbeadd13a843 /src/org/traccar/web/WebServer.java
parent3179094aacede295938f64e21178bbb6f7fa0867 (diff)
downloadtrackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.tar.gz
trackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.tar.bz2
trackermap-server-f8e2c913fd18c40025cc110cd7c4506b6038b123.zip
Use DefaultServlet instead of ResourceHandler
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r--src/org/traccar/web/WebServer.java16
1 files changed, 9 insertions, 7 deletions
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");