Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Jetty 6.x versus Tomcat 6.x

An AppFuse user asks:

Has anyone done any performance benchmarking between Jetty 6.x and Tomcat 6.x to see which one is better for production use in terms of scalability, performance and ease-of-use? I'm gearing towards Jetty 6.1 but want to hear other's opinions first.

I admit, I completely changed the wording in this quote to make it more readable.

Most of the companies I've worked with in recent years have been using Tomcat (very successfully) in production. However, I also know the Contegix and JavaLobby guys continue to swear by Resin for the most part. What's your opinion?

IMHO, I don't think it really matters - they're all good enough for production use.

Posted in Java at Aug 15 2007, 09:50:17 AM MDT 7 Comments
Comments:

My current project uses both. We use Jetty for basic, local testing and we're about to start using it for continuous integration testing with Selenium. We like it because it's so self-contained. I want as much control over my test environment as possible and using Jetty with Maven gives us that kind of control (not to imply we couldn't do pretty much the same thing with maven + tomcat + cargo too - but we don't). For staging however, we use Tomcat. I think the choice to go with Tomcat for the higher tiers is mostly just out of habit and the perceived pervasiveness of Tomcat (versus Jetty or Resin). Our app is so self-contained already, in that it doesn't rely on app-server services from bigger, fuller-featured servers like JBoss AS, that in the end, it likely doesn't matter what we run on.

Posted by Terry C. Martin on August 15, 2007 at 05:55 PM MDT #

Resin (w/ JRockIt JVM)

Posted by Vic on August 16, 2007 at 01:15 PM MDT #

Development - Tomcat standalone Production - Apache Web Server and Tomcat with AJP connector.

Posted by SM on August 16, 2007 at 03:17 PM MDT #

I don't know that you can embed Tomcat as well as you can embed Jetty. Once you get into testing with an embedded webserver it is very nice. Plus with webdriver giving you an embedded browser, web testing is looking a lot sweeter for me.

Posted by Joe Walker on August 16, 2007 at 10:16 PM MDT #

@joe:

Terrible simple to embed Tomcat:

File CATALINAHOME = new File("./var/catalina");
File WEBAPPS = new File(CATALINAHOME,"webapps");
File ROOT = new File(WEBAPPS, "ROOT");

Embedded server = new Embedded();
server.setCatalinaHome(CATALINAHOME.getAbsolutePath());

Engine engine = server.createEngine();
engine.setDefaultHost("localhost");

Host host = server.createHost("localhost", WEBAPPS.getAbsolutePath());
engine.addChild(host);

Context context = server.createContext("", ROOT.getAbsolutePath());
 context.setParentClassLoader(Thread.currentThread().getContextClassLoader());
host.addChild(context);

server.addEngine(engine);

//Http
Connector http = server.createConnector("localhost", 8282, false);
server.addConnector(http);
//Start the server 
server.start();

Pretty easy ;-)

Posted by 209.181.65.238 on August 18, 2007 at 04:17 AM MDT #

Hi, and how do you register servlets (not whole war files) to the context? Thanks!

Posted by RPR on April 10, 2008 at 10:50 AM MDT #

I just tried embedding both Jetty 6 and Tomcat 6. Jetty was much easier to get installed and running. I eventually went with Tomcat, though, as I couldn't get the Jetty JSP compiler to handle Java 1.5 constructs.

For those needing an example of how to embed Tomcat 6, here's my code:

    String noIdeaWhatThisDoes = absolutePath("build");
    String app = absolutePath("build/dist");
    tomcatServer = new Embedded();
    Engine engine = tomcatServer.createEngine();
    engine.setDefaultHost("localhost");

    Host host = tomcatServer.createHost("localhost", noIdeaWhatThisDoes);
    engine.addChild(host);

    StandardContext context = ((StandardContext) tomcatServer.createContext("", app));
    context.setWorkDir(absolutePath("build/testrun/tomcat-work"));
    context.setDefaultWebXml(absolutePath("tests/default_context_web.xml"));
    host.addChild(context);

    tomcatServer.addEngine(engine);
    Connector connector = tomcatServer.createConnector(InetAddress.getLocalHost(), port, false);
    tomcatServer.addConnector(connector);
    tomcatServer.start();

The bit about the default web.xml is to get the standard behaviors you'd expect from Tomcat, like processing JSPs. I just made a copy of conf/web.xml and trimmed it down. The work directory bit is necessary to keep it from using your library directory as a scratch area. And the app path should be the absolute path to your unpacked WAR. From the code, you may also be able to give it the WAR, but I didn't check.

Posted by William Pietri on January 20, 2009 at 01:06 AM MST #

Post a Comment:
  • HTML Syntax: Allowed