tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Apache+Tomcat+mod_jk+cookie+Rewrite
Date Fri, 05 Jan 2007 14:29:13 GMT
Hash: SHA1


> I notice that because of url rewriting [RewriteRule] my cookie is not
> being passed to Tomcat.

It's not your rewrite rule that is dropping your cookie. It's the fact
that you are changing the path of the URI.

> RewriteRule ^/url1$ /MyApp/MyServlet     [PT]

I'm guessing that your webapp emits a cookie with the path of "/MyApp".
If your app also emits URLs of the form http://whatever/url1/MyServlet,
then the browser will not send the cookie along with the request
(because the cookie belongs to /MyApp, not /url1).

You can probably verify this using a packet sniffer or a much more
convenient tool like LiveHttpHeaders for Mozilla Firefox or perhaps a
plug-in for MSIE or another browser.

> How do i go about passing the cookie to the servlet using RewriteRule ?

You will need to do one of several things:

1. Stop using this other URL.
2. Move that URL-to-be-re-written inside the URL space of your
   webapp (i.e. change /url1 to /MyApp/url1).
3. Modify your cookie configuration such that the path will be set
   to "/" instead of "/MyApp" (I think single-sign-op will do this,
   but there are probably other ways, too).
4. Use javascript to mutate the cookie and send (another copy) to
   the browser with the path of "/url1" (you're already using javascript
   in your onsubmit event handler, so this should always work).

I highly recommend #2. It's pretty easy, and you don't have to resort to
any hacks in your application to make it work (other than the obvious
hack of using mod_rewrite in the first place).

- -chris
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message