Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Apache+Tomcat+mod_jk+cookie+Rewrite

Christopher Schultz

2007-01-05

Replies:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Deval,

DEVAL SHAH wrote:
> 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFnmC59CaO5/Lv0PARAl+YAKCy7JXb2gmrG7Yv1jMRvlrXMqvmMACgoCEc
F9aJLnjBWwGCAJAkMdN01fU=
=A2S+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.