tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: mod_jk and session stickyness of images requests
Date Fri, 11 Dec 2009 15:42:19 GMT
Hash: SHA1


On 12/11/2009 10:27 AM, Kockert, Timo wrote:
> first time posting to this list, so please don't be too hard with me ;-)

Welcome to the list. Hey, you posted your relevant environment details,
a clear description of your problem, and admitted that the problem might
be your own code. What more could we ask for? :)

> 3 servers running Tomcat 5.5.x with AJP connector
> 2 servers running Apache webserver 2.2.x with mod_jk 1.2.28
> [using sticky sessions and non-distributed sessions]


> The problem is that our webapp renders images on-the-fly for incoming
> requests to content pages. That means, that image requests need use the
> same session as the request to the content page. They have to hit the
> same appserver because the images are just not present on the other
> appservers.

Got it.

> We configured our webapp to use cookies or - if cookies are not
> available - do url rewriting. This seems to work fine for say 90% of our
> requests. But it seems like some devices just don't send the session ID
> cookie with image requests. They send the cookie with the request to the
> content page but not with the following image requests.
> Could this be a configuration problem on our side? Or is this something
> some devices do wrong? If so, has anyone an idea how to circumvent this
> issue?

The most likely problem is that you are not properly encoding the URLs
that reference images. You see this problem a lot with page authors who
always have cookies enabled in their browsers, because it's easy to
forget. You have to encode your URLs properly if you want session
stickiness to work. Here's how:

<img src="<%= request.getContextPath() %><%=
response.encodeURL("/path/to/my/image.png") %>" />

This will add the ";jsessionid=..." parameter (along with the jvmroute)
to the image's URL, ensuring that it is sent to the right back-end server.

There are various tag libraries that properly-format URLs in this way so
you don't have to remember to do it yourself. Also, if you are using
some other output technology (Velocity, Freemarker, etc.), similar tools
should be available for those.

Hope that helps,
- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message