How to Embed tomcat in java

11,169

there's a more recent tutorial about embedding tomcat 8 here.

the gist of it:

public static void main(String[] args) throws Exception {
    Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);

    //actually deploy stuff on your tomcat by defining contexts          

    tomcat.start();
    tomcat.getServer().await();
}
Share:
11,169
cJ_
Author by

cJ_

Updated on June 08, 2022

Comments

  • cJ_
    cJ_ almost 2 years

    I am trying to embed tomcat in java application. I searched the google but no luck. i was not able to find good tutorial. is there any complete tutorials or api docs for embedding tomcat. this question might be duplicate of another question. but it seems old. I read that tomcat 7 api over tomcat 6 is lot improved. so i considered it as old. Any links for tutorials is appreciated.