Thanks. That was the way I was doing it in the filter (getting the dispatcher from the various contexts). I changed it. The good news is that the routing now works as expected. The bad news is that it is still bypassing the security stuff. I wasn't logged in, and it went straight to the protected page anyway. Ideas?
Jerry On Sun, Dec 25, 2011 at 6:58 PM, Konstantin Kolinko <knst.koli...@gmail.com>wrote: > 2011/12/26 Jerry Malcolm <2ndgenfi...@gmail.com>: > > Konstantin, > > > > Thanks for the info. I think I'm getting close. As a test, I have > created > > a valve that just forces a redirect. It compiled fine. I registered it > > under the 'host' tag next to the other valves in server.xml. When I > send a > > request in, my print statements write to System.out just as expected. > > > > The only problem is, the request forward goes nowhere. Just white screen > > on the browser. The requestDispatcher returns without any exceptions. > But > > I can't find anything in the logs saying anything was wrong. The code is > > simple: > > > > public void invoke(Request request, Response response) throws > IOException, > > ServletException { > > System.out.println( "in Valve" ); > > try { > > RequestDispatcher requestDispatcher = request.getRequestDispatcher( > > "/cismanager/jsp/user/home.jsp" ); > > In short, > 1) dispatcher is always relative to Context. > You must get Context first (from a Mapper?) and then get Dispatcher > from there. (Dropping the "cismanager" part from the URL). > > > If you were doing it from a Filter you would call > ServletContext.getContext(String) followed by > ServletContext.getRequestDispatcher(). > > Note that ServletContext.getContext(String) returns null for better > security, unless you explicitly set <Context crossContext="true"/> in > the target web application. > > 2) using a RequestDispatcher you will get the same result as with > using it from inside a Filter. That is it will be a usual "forward", > and auth constraints wouldn't apply. > > Here are tips for debugging Tomcat: > https://wiki.apache.org/tomcat/FAQ/Developing > > > > System.out.println( "should get here" ); > > requestDispatcher.forward( request, response ); > > System.out.println( "return from forward"); > > } > > catch( Throwable e) { > > e.printStackTrace( System.out ); > > } > > // getNext().invoke(request, response); > > } > > > > I figure it's something to do with the URL. I have never used a > > RequestDispatcher obtained from the Request object outside of a webapp > > context. From what you said, the valve is 'above' the contexts at the > > 'host' level. So I assume the parsing of the context out of the URL has > > yet to occur and therefore should happen in my 'forward'. Hence, I used > > the entire URL (after the domain name) in the forward. In the example > > above, I have the webapp mapped to "/cismanager". > > > > Am I close? Or is this totally wrong? Should I not use the > > RequestDispatcher? Should I somehow wrapper the request object and set > the > > new URL in that? > > > > Thanks again for all the help. > > > > Jerry > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >