2

I have built a web app with http4s that uses Jetty as Servlet container. The code below shows the implementation of the server:

@WebListener
class Bootstrap extends ServletContextListener with IOApp {


  override def contextInitialized(sce: ServletContextEvent): Unit = {
    val ctx = sce.getServletContext
    val blocker = Blocker.liftExecutionContext(ExecutionContext.global)
    ctx.mountService("user-svc", UserSvcRoutes.helloWorldRoutes[IO](HelloWorld.impl[IO]))
    ()
  }

  override def contextDestroyed(sce: ServletContextEvent): Unit = {}

  override def run(args: List[String]): IO[ExitCode] = ???
}

Then I have compiled as a WAR file and placed it into webapps sub-folder from the main jetty folder:

enter image description here

After the Jetty server gets started, it shows:

enter image description here

but I would like to get the main page of the service:

enter image description here

instead of clicking on:

enter image description here

to get into the service.

In the WEB-INF, I have created the file jetty-web.xml with the following content:

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC
    "-//Mort Bay Consulting//DTD Configure//EN"
    "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/user-svc</Set>
</Configure>

and does not work.

How to get the user-svc as root path /?

softshipper
  • 32,463
  • 51
  • 192
  • 400

0 Answers0