{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
ServletContainer container = ServletContainerFactory.getServletContainer();
WebAppRegistry registry = new WebAppRegistry();
if (container.addWebAppListener(registry))
{
try
{
WebApp app = registry.getWebApp("/rdapp");
if (app != null)
{
NormalCallback cb1 = new NormalCallback(app.getServletContext(), app.getClassLoader());
Exception ex = new Exception();
ExceptionCallback cb2 = new ExceptionCallback(app.getServletContext(), ex, ex);
Error err = new Error();
ExceptionCallback cb3 = new ExceptionCallback(app.getServletContext(), err, err);
RuntimeException rex = new RuntimeException();
ExceptionCallback cb4 = new ExceptionCallback(app.getServletContext(), rex, rex);
IOException ioe = new IOException();
ExceptionCallback cb5 = new ExceptionCallback(app.getServletContext(), ioe, ioe);
//
ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);
Throwable response = cb1.test(null, dispatcher);
response = cb2.test(response, dispatcher);
response = cb3.test(response, dispatcher);
response = cb4.test(response, dispatcher);
response = cb5.test(response, dispatcher);
//
if (response != null)
{
throw new ServletException(response);
}
else
{
resp.setStatus(200);
}
}
else
{
resp.sendError(500, "Could not find application among " + registry.getKeys());
}
}
finally
{
container.removeWebAppListener(registry);
}
}
else
{
resp.sendError(500, "Could not add registry as web app listener");