Если я правильно понял ваш вопрос при запуске приложения, вы хотите, чтобы ваша страница отображалась как страница по умолчанию, перейдите по ссылке ниже
Как настроить список файлов приветствия в web.xml
Это позволит вам узнать, как настроить страницу web.xml, чтобы tomcat или любой другой веб-контейнер знал вашу страницу по умолчанию.
вы можете попробовать это
public class Test {
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
server.createContext("/welcomePage", new MyHandler());
server.setExecutor(null); // creates a default executor
server.start();
}
static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
String response = "This is the response";
// we do not set content type, headers, cookies etc.
// resp.setContentType("text/html"); // while redirecting as
// it would most likely result in an IllegalStateException
// "/" is relative to the context root (your web-app name)
RequestDispatcher view = req.getRequestDispatcher("/path/to/file.html");
// don't add your web-app name to the path
view.forward(req, resp);
}
}
}