<p>The problem is simple, but I'm struggling a bit already.</p>

<pre><code>Server server = new Server(8080);  
Context context = new Context(server, "/", Context.NO_SESSIONS);
context.addServlet(MainPageView.class, "/");
context.addServlet(UserView.class, "/signup");
server.start();
</code></pre>

<p>That's a pretty standard piece of code that you can find anywhere in Jetty world. I have an application that embeds Jetty as a servlet engine and has some servlets. </p>

<p>Instantiation of some of these servlets requires heavy work on startup. Say &ndash; reading additional config files, connecting to the database, etc. How can I make the servlet engine instantiate all servlets eagerly, so that I can do all the hard work upfront and not on the first user request?</p>

Use the
```
Context.addServlet
```
overload that takes a
```
ServletHolder
```
.
```
ServletHolder
```
is a class that accepts either a Class or a Servlet instance.
```
```
Servlet myServlet = new MyServlet();
ServletHolder holder = new ServletHolder(myServlet);
context.addServlet(holder, "/");
```
```
This assumes Jetty 6.  I think it will work for Jetty 7 as well.