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.
Asked
Active
Viewed 1.1k times
1 Answers
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
-
would you please say something about how to stop the running tomcat?just `tomcat.getServer().stop();`. – Ron Nov 21 '15 at 14:53
-
1
-
Here's another good tutorial on how to embed Tomcat, for Tomcat 8. http://www.jofre.de/?p=1227 – michaelok Oct 25 '16 at 16:54