如何使用 Tyrus websocket 服务器部署 .jsp?

How to deploy .jsp with Tyrus websocket server?

所以我有一个服务器端点,它使用 Tyrus 通过 websocket 服务器部署。我编写的几个 swing 应用程序使用此服务器端点进行通信。但是,我还想在同一台服务器上部署一个 .jsp 网页。

截至目前,我能够访问 .jsp 页面,但它在浏览器中显示为代码,而不是生成正确的 html.

package com.server;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import javax.websocket.DeploymentException;

import org.glassfish.tyrus.server.Server;

import com.util.DiscordLogger;

public class Main {

    public static DiscordLogger discord = new DiscordLogger();

    public static void main(String args[]) {
        final Map<String, Object> serverProperties = new HashMap<String, Object>();
        serverProperties.put(Server.STATIC_CONTENT_ROOT, "./WebContent"); //folder with .jsp file
        Server server = new Server("localhost", 8080, "/Server", serverProperties,
                com.websocket.WebSocketServer.class);
        try {
            server.start();
            System.out.println("Press any key to stop the server..");
            new Scanner(System.in).nextLine();
        } catch (DeploymentException e) {
            throw new RuntimeException(e);
        } finally {
            server.stop();
        }
    }

}

Tyrus 是纯粹的WebSockets 实现,不支持JSP。要使用 JSPs,您需要一个 servlet 容器,例如 Tomcat 或 Payara Micro。