I'm trying to automatically assign a context path to requests from a specific
URL using a Valve, so in the following example code requests to the URL
http://www.site2.com should hit my <Context> in server.xml with the path
"/site2" :

public void invoke(Request request, Response response) throws
java.io.IOException, javax.servlet.ServletException {
        if(request.getRequestURL().indexOf("www.site2.com") != -1) {
                request.setContextPath("/site2");
                System.out.println("Context path set to " + 
request.getContextPath());
        }
        getNext().invoke(request, response);
}

The system out is being called so I would have expected the same behaviour
that I get when I type http://www.site2.com/site2 into the browser. However,
the default <Context> is being hit.

Is this something anyone has tried to do using a Valve or is there any
better way to achieve this kind of behaviour. Any advice would be very much
appreciated.

Ronny.
-- 
View this message in context: 
http://www.nabble.com/Adding-contextPath-to-request-using-a-Valve-tp18737761p18737761.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to