7

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.

Community
  • 1
  • 1
cJ_
  • 486
  • 1
  • 4
  • 19

1 Answers1

14

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();
}
radai
  • 23,949
  • 10
  • 71
  • 115