Question

I'm setting up an Embedded Jetty server as per the following:

Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");

ServletHandler handler = new ServletHandler();
context.addServlet(new ServletHolder(new CustomServlet()),"/*");

context.setHandler(handler);
server.setHandler(context);

try {
    server.start();
} catch (Exception e) {
    e.printStackTrace();
}

I'd like to add the following parameters programmatically.

<Context>
  <Valve className="a.ClassA" />
  <Realm className="b.ClassB" />
</Context>

How can I do this?

Was it helpful?

Solution

The jetty xml is simply a thin skin over java itself, so anything you can do in the jetty xml you can do in an embedded way.

This is a link to our documentation on embedding jetty.

http://www.eclipse.org/jetty/documentation/current/advanced-embedding.html

It is not really clear to me what you are trying to do here, but the follow example explains a bit about security realms, etc.

http://www.eclipse.org/jetty/documentation/current/embedded-examples.html#embedded-secured-hello-handler

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top