aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/web/WebServer.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index 0ed5d013e..9af9fd33a 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -68,16 +68,17 @@ import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.net.InetSocketAddress;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.EnumSet;
public class WebServer implements LifecycleObject {
private static final Logger LOGGER = LoggerFactory.getLogger(WebServer.class);
- private Server server;
-
- private void initServer(Config config) {
+ private final Server server;
+ public WebServer(Config config) {
String address = config.getString(Keys.WEB_ADDRESS);
int port = config.getInteger(Keys.WEB_PORT);
if (address == null) {
@@ -85,11 +86,6 @@ public class WebServer implements LifecycleObject {
} else {
server = new Server(new InetSocketAddress(address, port));
}
- }
-
- public WebServer(Config config) {
-
- initServer(config);
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
@@ -106,8 +102,13 @@ public class WebServer implements LifecycleObject {
@Override
protected void handleErrorPage(
HttpServletRequest request, Writer writer, int code, String message) throws IOException {
- writer.write("<!DOCTYPE><html><head><title>Error</title></head><html><body>"
- + code + " - " + HttpStatus.getMessage(code) + "</body></html>");
+ if (code == HttpStatus.NOT_FOUND_404 && request.getPathInfo().startsWith("/modern")) {
+ writer.write(Files.readString(
+ Paths.get(config.getString(Keys.WEB_PATH), "modern", "index.html")));
+ } else {
+ writer.write("<!DOCTYPE><html><head><title>Error</title></head><html><body>"
+ + code + " - " + HttpStatus.getMessage(code) + "</body></html>");
+ }
}
});