|
From: Jan S. <jan...@gm...> - 2007-10-17 18:04:27
|
I'm having some problems deciding how to best set up my embedded Jetty
server. The use case is as follows:
- I have a number of servlets that are mapped below the root "/" context.
So, each servlet is at "/servletA", "servletB" etc.
- Now I need to add another servlet that is mapped to a context below the
others, i.e. "sub/servletX". (Actually, the single servlet has multiple
mappings at this level)
So far I have the following setup:
Server -> ServletContext("/") -> ServletHandler -> a number of (Servlet
Holder -> Servlet), each with its own mapping.
I tried adding the new servlet by specifying ("sub/servletX)" as the context
when adding it to the top level servlet handler, but this didn't work. It
seems I can only map to a top level path when adding servlets to this, i.e.
the context can't contains any "/"'s . Is this the case?
I realise I may need to add another ContextHandler for the sub-context. I'm
not clear on how to best do this though. I see two options:
1. Add another servlet context with ("/sub") at the same level as the
existing ServletContext for "/", then add "servletX" to this.
or
2. Add a ContextHandler as a sub-handler of the ServletHandler, with "sub"
as context path, and add the servlet to this.
I suspect option 2 is the right one, as otherwise the servlet context would
"swallow" all requests, as it maps to the "/" path. Is this correct?
Any comments on whether I'm going in the right direction would be highly
appreciated. (I'm using Jetty 6.1.4 on Java 6)
Thanks,
Jan
|