| // ======================================================================== |
| // Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. |
| // ======================================================================== |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // and Apache License v2.0 which accompanies this distribution. |
| // |
| // The Eclipse Public License is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| // |
| // The Apache License v2.0 is available at |
| // http://www.opensource.org/licenses/apache2.0.php |
| // |
| // You may elect to redistribute this code under either of these licenses. |
| // ======================================================================== |
| |
| [[embedded-one-webapp]] |
| ==== Web Application |
| |
| This example shows how to deploy a simple webapp with an embedded instance of Jetty. |
| This is useful when you want to manage the lifecycle of a server programmatically, either within a production application or as a simple way to deploying and debugging a full scale application deployment. |
| In many ways it is easier then traditional deployment since you control the classpath yourself, making this easy to wire up in a test case in Maven and issue requests using your favorite http client library (like our Jetty client found in xref:http-client[]). |
| |
| [source, java, subs="{sub-order}"] |
| ---- |
| include::{SRCDIR}/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java[] |
| |
| ---- |
| |
| ===== Run it! |
| |
| After you have started things up you should be able to navigate to http://localhost:8080/ and you are good to go. |
| |
| ===== Maven Coordinates |
| |
| To use this example in your project you will need the following Maven dependencies declared. |
| |
| [source, xml, subs="{sub-order}"] |
| ---- |
| |
| <dependency> |
| <groupId>org.eclipse.jetty</groupId> |
| <artifactId>jetty-webapp</artifactId> |
| <version>${project.version}</version> |
| </dependency> |
| |
| |
| ---- |