On 10/19/05, Michael P. Soulier <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I didn't find this in the archives, so I'll ask.
>
> I have a tomcat app deployed via proxypass from apache (2 in fact, a
> double-proxy through 2 servers). It needs to use relative paths in its
> links to ensure that the composed path is correct. Unfortunately struts
> doesn't seem to want to use relative links.

So,
> 1. Is there a way to make it use a relative link instead of an absolute
> one?


I wonder why Struts doesn't handle the "relative" links (ie Relative to the
current servlet) at all. In the RequestProcessor's processForwardConfig,
there is in fact a comment saying "paths not starting with / should be
passed through without any processing
(ie. they're absolute)" [or "relative" to the current servlet]
And it calls the doForward to do the forward which just gets the
RequestDispatcher from the ServletContext. The J2EE API says that the
RequestDispatcher acquired from the ServletContext expects a path starting
with "/". I think if the path doesn't start with a "/" then the doForward
should be getting the RequestDispatcher from the Request which accepts links
"relative" to the current servlet. Is this a bug or am I missing something?
Anyway for you current task, I guess you can override the RequestProcessor's
doForward to handle the links "relative" to the current servlet using the
RequestDispatcher from the request.

2. Is there a way to force a prefix on the link?


I think you can do the following way, but I don't know if it's recommended.
Basically you would create a prefix or a module like "/foo/bar/me". (Just
loading the config file with a contextParam config/foo/bar/me for the
struts-config.xml). Struts will make the module or the path prefix as part
of the links and you have to also make the contextPath to be "/" instead of
"me" to the Struts App. One way would be to have a Filter which just wraps
the request with HttpRequestWrapper and overriding the getContextPath to
return "/". But for the outside world and the proxies the contextPath would
still be "me" and everything should work as normal for those.

Basically, the tomcat app is deployed as application "me". Instead of
> links like
>
> /me
>
> I want
>
> /foo/bar/me
>
> Is this possible?
>
> Thanks,
> Mike
>
> --
> Michael P. Soulier <[EMAIL PROTECTED]>, 613-592-2122 x2522
> Linux applications development
> "...the word HACK is used as a verb to indicate a massive amount of
> nerd-like effort." -Harley Hahn, A Student's Guide to Unix
>
>
>

Reply via email to