On Monday 13 August 2007 11:24, David Leangen wrote:
> The spec mentions that, understandably, two different servlets cannot be
> registered under the same alias. However, I see no mention either way of
> registering the same servlet under two different aliases. I don't see
> why this should be illegal...
The spec mentions that ServletException should be thrown if the Servlet has
been registered under a different alias. See 102.11.3.3 in Release 4.0.1
I suspect that there are problems in the servlet spec, since one can ask for
the ServletContext for the base URL, which would then need to be generated
per request (whether needed or not), or something like that. I'd be happy to
hear about the background for this part of the spec, if anyone remembers...
The obvious work-around would be a servlet delegator.
public class ServletDelegator extends HttpServlet
{
private HttpServlet delegate;
public ServletDelegator( HttpServlet delegate )
{
this.delegate = delegate;
}
public void init()
{
delegate.init();
}
public void service( HttpServletRequest req, HttpServletResponse resp )
{
delegate.service( req, resp )
}
:
}
and then create two instances of the above with the same delegate, and mount
those separately. Note that you will need to deal with the above mentioned
context issue.
Cheers
--
Niclas Hedhman, Software Developer
I live here; http://tinyurl.com/2qq9er
I work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev