Ouch! But the answer is easy. Filters with HttpServletResponseWrapper. Here is a quick example:

public class NoRewriteFilter implements Filter {

    public void init(FilterConfig filterConfig)
              throws ServletException {
        ;
    }

    public void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain chain)
                  throws IOException,
                         ServletException {

if (canIgnoreRewrite(request)) {
response = new HttpServletResponseWrapper((HttpServletResponse)response) {
public String encodeRedirectUrl(String url) {
return url;
}
public String encodeRedirectURL(String url) {
return url;
}
public String encodeUrl(String url) {
return url;
}
public String encodeURL(String url) {
return url;
}
}
chain.doFilter(request,response);
}


    public void destroy() {
        ; // no-op
    }


protected boolean canIgnoreRewrite(ServletRequest request) { HttpServletRequest r = (HttpServletRequest)request; String agent = r.getHeader("user-agent");

        if (agent!=null)
            return false;
        agent = agent.toLowerCase();
        return agent.indexOf("googlebot")>-1;
    }

}




-Tim


Mike Heckler wrote:
Is there a way to tell tomcat to NOT place the session ID in a url
(even when the client doesn't support cookies) based on IP or user-agent?

The problem I'm having is with search engines (especially google) not indexing
my entire site because the URLs have the jsessionid in them. I'd like to support
browsers with cookies turned off, but at the same time not send the jsessionids
to certain clients.


I've looked around and can't seem to even the question anywhere, let alone the answer.

Thanks,
Mike Heckler


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to