java - Define main servlet for scalatra/jetty at build/runtime -


I have a skeleton server with JTD embedded and the initialization code for two is listed below, where HelloServlet < Loading / code> is the main servlet.

Is there any way that I can set up this servlet or set it on runtime?
I do not want to use XML to configure because I use these methods

JT startup

  public class example server {public static zero Main (string [] args) exception {server server = new server (); ServerConnector Connector = New ServerConnector (Server); Connector.setport (8080); Server.setConnectors (new connector [] {connector}); ServletContextHandler Reference = New ServletContextHandler (); Context.setContextPath ("/ Hello"); Context.addServlet (HelloServlet.class, "/"); // can it be defined later ?? Handler Collection Handler = New Handler Collection (); Handlers. Setholders (new handler [] {reference, new default handler ()}); Server.setHandler (handler); Server.start (); Server.join (); }}  

Scalattra startup

  class ScalatraBootstrap increases LifeCycle {override def init (reference: ServletContext) {context. Mount (new heloservlet, "/ *") // Can it be defined later ?? }}  


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -