jueves, enero 27, 2011

Ay Ay Ay Amor Yo Soy Satélite y Tú Eres Mi Sol






Tomcat 7 comes with a lot of new features, like Servlet 3.0 specification, filter for preventing CSRF attacks, and more and more features. One feature that I really like is the simplicity that has acquired embedding a Tomcat into an application.

First of all you are not required to download all archives; there is a separated link for downloading only required jars

Second one is how easy is to create a tomcat instance and add the directory where web application is deployed.

String webApp = ...;
String tomcatDir = ...;

Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir(tomcatDir);
tomcat.setHostname("localhost");

tomcat.addWebapp("/", webApp);
tomcat.start();
tomcat.getServer().await();


Only three sections:
  • Configure Tomcat. The base directory for temp files.
  • Adding information about where web application is deployed and which context path should serve it.
  • Starting server and waits until application is closed.


I have not found in Tomcat documentation something like Jetty that you can set a War file and container is the responsible for unpacking it. I think that in case of Tomcat some actions should be taken by developer for unpacking it.

I am not going to discuss about what embedded server is better, if Jetty or Tomcat, each one have their features, and their advantages and disadvantages, this post is only written as a resource for teaching how to embed tomcat into an application.

2 comentarios:

Anónimo dijo...

I seldom leave comments on blog, but I have been to this post which was recommended by my friend, lots of valuable details, thanks again.

Meiqing Xu dijo...

pandora outlet
birkenstocks
timberland boots
louis vuitton outlet
ray ban sunglasses discount
michael kors handbags
gucci purses
pandora
michael kors outlet
michael kors handbags
20170123caiyan

Donate If You Can and Find Post Useful