We have encountered a minor problem using Struts with our back end
architecture at Fidelity Investments.

Using Struts version 1.0, all action references always end up translated
to absolute paths when the JSP is translated to HTML.  For example, an
action="foo.do" in a JSP is later converted into action="/foo.do" in the
resulting HTML file, even if it actually needs to remain a relative
reference "foo.do" in order to work in our back end architecture.  This
is no real surprise I suppose, as the use of the absolute slash is
mentioned in the Struts specification.

As a result, we are considering hacking the Struts code in a couple of
places to strip the absolute slash off of the front of the action
reference path name before writing the HTML, and then re-adding it back
again on the action mapping.  After some investigation, it appears that
this hack can be isolated to two spots:

1.  org.apache.struts.util.ResponseUtils.write :
     Code to strip the prefixed slash from the beginning of the
action="" string just before it is written out to the response.

2.  org.apache.struts.action.ActionMappings.findMapping :
     Code to prefix  the slash back onto the front of the action=""
string (assuming the mapping can't be found without it).

This seems to be the least painful solution because it seems to be
isolated to two spots in the code and it does not involve hacking any
taglibs which we don't want to touch since we would forever be hacking
new taglibs for the rest of time.

Preliminary testing would indicate that this hack does seem to work, but
I can't help but wonder: are we missing something?  Is there an easier,
more elegant way to achieve relative paths in action parameter
references?

Thanks,

David McLure

[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to