Package org.eclipse.jetty.embedded
Class ManyHandlers
- java.lang.Object
-
- org.eclipse.jetty.embedded.ManyHandlers
-
public class ManyHandlers extends java.lang.Object
Frequently many handlers are combined together to handle different aspects of a request. A handler may:- handle the request and completely generate the response
- partially handle the request, but defer response generation to another handler.
- select another handler to pass the request to.
- use business logic to decide to do one of the above.
HandlerWrapper
which will nest one handler inside another. In this example, the HelloHandler is nested inside a HandlerWrapper that sets the greeting as a request attribute.HandlerList
which will call a collection of handlers until the request is marked as handled. In this example, a list is used to combine the param handler (which only handles the request if there are parameters) and the wrapper handler. Frequently handler lists are terminated with theDefaultHandler
, which will generate a suitable 404 response if the request has not been handled.HandlerCollection
which will call each handler regardless if the request has been handled or not. Typically this is used to always pass a request to the logging handler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ManyHandlers.ParamHandler
Produce output that lists all of the request parametersstatic class
ManyHandlers.WelcomeWrapHandler
Add a request attribute, but produce no output.
-
Constructor Summary
Constructors Constructor Description ManyHandlers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Server
createServer(int port)
static void
main(java.lang.String[] args)
-
-
-
Method Detail
-
createServer
public static Server createServer(int port) throws java.io.IOException
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-