@Override
public void dispatch() {
- // TODO SERVLET3 - async
+ HttpServletRequest sr = (HttpServletRequest)getServletRequest();
+ String path = sr.getRequestURI();
+ dispatch(path);
}
@Override
try {
//piggy back on the request dispatcher to ensure that filters etc get called.
//TODO SERVLET3 - async should this be include/forward or a new dispatch type
+ //javadoc suggests include with the type of DispatcherType.ASYNC
requestDispatcher.include(servletRequest, servletResponse);
}catch (Exception x) {
//log.error("Async.dispatch",x);
import java.io.IOException;
import java.util.EnumSet;
+import javax.servlet.DispatcherType;
import javax.servlet.SessionTrackingMode;
import org.apache.catalina.CometEvent;
boolean success = true;
try {
+ DispatcherType prevDispatcherType = request.getDispatcherType();
+ request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.ASYNC);
// Calling the container
try {
connector.getContainer().getPipeline().getFirst().invoke(request, response);
}catch (RuntimeException x) {
success = false;
+ } finally {
+ request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, prevDispatcherType);
}
if (request.isComet()) {
}
public Void run() throws ServletException, IOException {
- doInclude(request,response);
+ DispatcherType type = DispatcherType.INCLUDE;
+ if (request.getDispatcherType()==DispatcherType.ASYNC) type = DispatcherType.ASYNC;
+ doInclude(request,response,type);
return null;
}
}
throw (IOException) e;
}
} else {
- doInclude(request,response);
+ DispatcherType type = DispatcherType.INCLUDE;
+ if (request.getDispatcherType()==DispatcherType.ASYNC) type = DispatcherType.ASYNC;
+ doInclude(request,response,type);
}
}
- private void doInclude(ServletRequest request, ServletResponse response)
+ private void doInclude(ServletRequest request, ServletResponse response, DispatcherType type)
throws ServletException, IOException
{
// Set up to handle the specified request and response
if (servletPath != null)
wrequest.setServletPath(servletPath);
wrequest.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
- DispatcherType.INCLUDE);
+ type);
wrequest.setAttribute(
ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
getCombinedPath());
}
wrequest.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
- DispatcherType.INCLUDE);
+ type);
wrequest.setAttribute(
ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
getCombinedPath());
servlet = null;
}
MessageBytes requestPathMB = request.getRequestPathMB();
+ DispatcherType dispatcherType = DispatcherType.REQUEST;
+ if (request.getDispatcherType()==DispatcherType.ASYNC) dispatcherType = DispatcherType.ASYNC;
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
- DispatcherType.REQUEST);
+ dispatcherType);
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
requestPathMB);
<%@page session="false"%>
Output from async1.jsp
+Type is <%=request.getDispatcherType()%>
<%
System.out.println("Inside Async 1");
if (request.isAsyncStarted()) {