final String old_servlet_name=base_request.getServletName();
final String old_servlet_path=base_request.getServletPath();
final String old_path_info=base_request.getPathInfo();
final Map old_role_map=base_request.getRoleMap();
Object request_listeners=null;
ServletRequestEvent request_event=null;
try
{
ServletHolder servlet_holder=null;
FilterChain chain=null;
// find the servlet
if (target.startsWith("/"))
{
// Look for the servlet by path
PathMap.Entry entry=getHolderEntry(target);
if (entry!=null)
{
servlet_holder=(ServletHolder)entry.getValue();
base_request.setServletName(servlet_holder.getName());
base_request.setRoleMap(servlet_holder.getRoleMap());
if(Log.isDebugEnabled())Log.debug("servlet="+servlet_holder);
String servlet_path_spec=(String)entry.getKey();
String servlet_path=entry.getMapped()!=null?entry.getMapped():PathMap.pathMatch(servlet_path_spec,target);
String path_info=PathMap.pathInfo(servlet_path_spec,target);
if (type==INCLUDE)
{
base_request.setAttribute(Dispatcher.__INCLUDE_SERVLET_PATH,servlet_path);
base_request.setAttribute(Dispatcher.__INCLUDE_PATH_INFO, path_info);
}
else
{
base_request.setServletPath(servlet_path);
base_request.setPathInfo(path_info);
}
if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)
chain=getFilterChain(type, target, servlet_holder);
}
}
else
{
// look for a servlet by name!
servlet_holder=(ServletHolder)_servletNameMap.get(target);
if (servlet_holder!=null && _filterMappings!=null && _filterMappings.length>0)
{
base_request.setServletName(servlet_holder.getName());
chain=getFilterChain(type, null,servlet_holder);
}
}
if (Log.isDebugEnabled())
{
Log.debug("chain="+chain);
Log.debug("servlet holder="+servlet_holder);
}
// Handle context listeners
request_listeners = base_request.takeRequestListeners();
if (request_listeners!=null)
{
request_event = new ServletRequestEvent(getServletContext(),request);
final int s=LazyList.size(request_listeners);
for(int i=0;i<s;i++)
{
final ServletRequestListener listener = (ServletRequestListener)LazyList.get(request_listeners,i);
listener.requestInitialized(request_event);