I need to add jetty servlet into my already existing server implemented using dropwizard framework.
To be more specific:
I could not get a clue how to do this after some googlings. Could someone please give me a direction or a snippet? Thanks!
If you're using Dropwizard 0.6.2 you should be able to do something like this in your run
method:
ServletBuilder builder = environment.addServlet(myServlet, "/bar");
If you're using Dropwizard 0.7.0 try this:
environment.getApplicationContext().addServlet("org.example.MyServlet", "/bar");
For 0.7.0 you have the ServletEnvironment
and a couple of ways to add servlets. For example:
@Override
public void run(ApplicationConfiguration configuration, Environment environment) throws Exception {
environment.servlets().addServlet("foo", MySerlvet.class).addMapping("/bar");
}
Incidentally, you also have the AdminEnvironment
, which is an extension of ServletEnvironment
and any servlets added to this in the same way would accessible on /admin/bar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With