aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-09-18 11:54:59 (EDT)
committerThomas Becker2013-09-18 11:55:24 (EDT)
commit016fbbb07f0595df925f3e0d4a5a3c6188cff04d (patch)
treecf2dfefa3c3aead2b6fda7e805933af972b9c345
parent6377503caa130b705aa80eb2ed2a80e177301cfe (diff)
downloadorg.eclipse.jetty.project-016fbbb07f0595df925f3e0d4a5a3c6188cff04d.zip
org.eclipse.jetty.project-016fbbb07f0595df925f3e0d4a5a3c6188cff04d.tar.gz
org.eclipse.jetty.project-016fbbb07f0595df925f3e0d4a5a3c6188cff04d.tar.bz2
416453 Add comments to embedded MinimalServlets example
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java
index 5d371e2..81e2e7d 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/MinimalServlets.java
@@ -32,10 +32,20 @@ public class MinimalServlets
{
public static void main(String[] args) throws Exception
{
+ // Create a basic jetty server object that will listen on port 8080. Note that if you set this to port 0
+ // then a randomly available port will be assigned that you can either look in the logs for the port,
+ // or programmatically obtain it for use in test cases.
Server server = new Server(8080);
+
+ // The ServletHandler is a dead simple way to create a context handler that is backed by an instance of a
+ // Servlet. This handler then needs to be registered with the Server object.
ServletHandler handler = new ServletHandler();
server.setHandler(handler);
+ // Passing in the class for the servlet allows jetty to instantite an instance of that servlet and mount it
+ // on a given context path.
+
+ // !! This is a raw Servlet, not a servlet that has been configured through a web.xml or anything like that !!
handler.addServletWithMapping(HelloServlet.class,"/*");
server.start();