You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jonathan Corbin <jo...@paytec.com> on 2005/04/13 21:36:47 UTC
Using Apache URL Rewriting with Struts?
I'm using RewriteRule directives in my Apache config to redirect certain URLs
to struts webapps, running under tomcat.
RewriteRule ^/my/webapp/url/(.*) /my-webapp/$1?paramIWantToAdd=31337
[QSA,PT]
This works fine, until it hits Struts code. Struts seems to be hard coded to
write server relative URLs. So links on a page produced by struts have the
wrong URL.
<form action="/my-webapp/action.do">
I would rather struts produce the following:
<form action="action.do">
so that the /my/webapp/url is preserved, and the user never sees /my-webapp.
Another related problem is with session cookies. Struts writes session
cookies at the app context (which I believe is what the servlet spec
requires), so the JSESSIONID cookie is written for the /my-webapp context,
and as a result, is not sent in on the HttpRequest when a user requests
a /my/webapp/url page.
I've successfully gotten around both problems by hacking the struts code a
little, and disabling session cookies (instead using session tracking through
URL rewriting, putting jsessionid=blah on the end of every url). I'd like to
avoid using a modified version of struts, however, so I'm wondering if there
is a better way to accomplish URL rewriting.
The real goal of all my modifications is to have each user of my application
use a different url, so that I can easily control what version of my
application they are using.
So user A goes to http://webserver/appForA
and user B goes to http://webserver/appForB
both get redirected to version 1 of my app at
http://webserver/appv1
Then, a few months down the road, I want to move user A to version 2, but keep
user b at version 1.
So I change user A's redirect to point to http://webserver/appv2
Is there a better way to accomplish this? Or am I stuck with Struts hacks for
the time being?
--
Jonathan Corbin
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Apache URL Rewriting with Struts?
Posted by Robin Ericsson <lo...@localhost.nu>.
Jonathan Corbin wrote:
> Is there a better way to accomplish this? Or am I stuck with Struts hacks for
> the time being?
You could try rewriting the url in your appserver instead. Haven't got
time to try it myself yet though :(.
http://tuckey.org/urlrewrite/
--
Robin Ericsson
http://robin.vill.ha.kuddkrig.nu/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org