if (servletContext != null) {
return new ServletTilesRequestContext(servletContext,
(HttpServletRequest) request,
(HttpServletResponse) response);
} else if (portletContext != null) {
PortletTilesApplicationContext app = (PortletTilesApplicationContext) context;
return new PortletTilesRequestContext(app.getPortletContext(),
(PortletRequest) request,
(PortletResponse) response);
} else {
throw new IllegalArgumentException("Invalid context specified. "
+ context.getClass().getName());