You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sergio <se...@strategos.com.br> on 2011/04/06 14:19:44 UTC

Valve to intercept outgoing requests

I made this Valve, trying to intercept requests going out of my 
"WebPages" context to the "Webservices" context. Right now they are both 
running in the same Tomcat (5.5.33), but that may not be true in the future.

public class TestValve extends org.apache.catalina.valves.ValveBase {
     @Override
     public void invoke(Request request, Response response) throws 
IOException, ServletException {
         System.out.println("TestValve");

         if (request.getRequestURI().contains("/WebPages")) {
             System.out.println("TestValve: context /WebPages");
             String teste = (String) 
request.getSession().getAttribute("test");
             request.setAttribute("test", teste);
         }

         getNext().invoke(request, response);
     }
}

The idea is to intercept the request to implicitly set attributes to be 
recovered at the "Webservices" context. This is not working. Any ideas why?

Sergio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Valve to intercept outgoing requests

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Apr 6, 2011 at 5:19 AM, Sergio <se...@strategos.com.br> wrote:
> I made this Valve, trying to intercept requests going out of my "WebPages"
> context to the "Webservices" context.

An outbound request made by your webapp for another resource is
not going to be using a Tomcat connector.

You could capture the *inbound* request to your "Webservices" or
fix your app to include the desired parameters (not attributes).

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org