aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-31 07:20:01 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-31 07:20:01 -0700
commitf028f926ad1c59268c591d1f095f0f77e36a814a (patch)
tree55c6add8633e199aba9693bd3982e2b91e14149e /src/main
parent346441e52256bca70b88dc6adad6bd3aa97da2a1 (diff)
downloadtrackermap-server-f028f926ad1c59268c591d1f095f0f77e36a814a.tar.gz
trackermap-server-f028f926ad1c59268c591d1f095f0f77e36a814a.tar.bz2
trackermap-server-f028f926ad1c59268c591d1f095f0f77e36a814a.zip
Better missing file handing
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/web/WebServer.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index 68eee78e7..704a4b3cd 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -64,6 +64,7 @@ import java.io.IOException;
import java.io.Writer;
import java.net.InetSocketAddress;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.EnumSet;
@@ -104,9 +105,9 @@ public class WebServer implements LifecycleObject {
@Override
protected void handleErrorPage(
HttpServletRequest request, Writer writer, int code, String message) throws IOException {
- if (code == HttpStatus.NOT_FOUND_404 && request.getPathInfo().startsWith("/modern")) {
- writer.write(Files.readString(
- Paths.get(config.getString(Keys.WEB_PATH), "modern", "index.html")));
+ Path index = Paths.get(config.getString(Keys.WEB_PATH), "index.html");
+ if (code == HttpStatus.NOT_FOUND_404 && Files.exists(index)) {
+ writer.write(Files.readString(index));
} else {
writer.write("<!DOCTYPE><html><head><title>Error</title></head><html><body>"
+ code + " - " + HttpStatus.getMessage(code) + "</body></html>");