Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-136

Use of RequestUtils.absoluteURL() in LinkTag [and RedirectTag] unnecessary and prevents complex deployments like with SSL accelerators

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Build
    • 1.0.0
    • Tag Libraries
    • None
    • Operating System: All
      Platform: All
    • 1356

    Description

      See attached emails from struts-dev@jakarta.apache.org for background about
      this issue.

      I've created relatively simple patches for this issue. See the attached
      "struts_relative_url_patch.zip" file (or
      "http://users.erols.com/sukachevin/struts/struts_relative_url_patch/" to browse
      through it on-line). Note that the patch addresses STR-131 as well.

      The following is the contents of the readme file for the patches
      ("http://users.erols.com/sukachevin/struts/struts_relative_url_patch/_readme.txt
      "):

      ----------------------------------------

      The following files show a patch for the issue where certain Struts custom
      tags unnecessarily convert a hyperlink to an absolute URL. Absolute URLs
      calculated by the servers often cause problems for web systems deployed with SSL
      accelerators that make the web requests appear to be HTTP when in fact it was
      HTTPS. Therefore, web pages should omit the scheme, server, and port in general
      so as to support a wider variety of deployments. For cases like redirection,
      an absolute URL may need to be specified for a forward instance's path
      attribute, so the patch allows for this as well [note that ActionServlet
      kind of allows for this already when it does a redirection because of a
      returned forward instance from the Action since ActionServlet only prepends
      request.getContextPath() to the path attribute value of the forward
      instance if the value starts with "/" – if the value does not, like in
      the case of an absolute URL, then ActionServlet uses the value
      as-is].

      04/13/01 04:39p 878 org.apache.struts.util.RequestUtils_patch.txt
      04/13/01 04:36p 822 org.apache.struts.taglib.bean.IncludeTag_patch.txt
      04/13/01 04:36p 1,085 org.apache.struts.taglib.html.LinkTag_patch.txt
      04/13/01 04:38p 1,105 org.apache.struts.taglib.logic.RedirectTag_patch.txt
      04/13/01 09:24a 757 org.apache.struts.taglib.logic.ForwardTag_patch.txt
      04/13/01 09:19a 757 org.apache.struts.taglib.ForwardTag_patch.txt

      Notes for org.apache.struts.util.RequestUtils_patch.txt:
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Added an isAbsoluteURL(String) static method that returns whether the specified
      URL string is an absolute URL string or not.

      Notes for org.apache.struts.taglib.bean.IncludeTag_patch.txt:
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Patch allows for the tag to use a forward instance whose path is an absolute
      URL. So if the forward instance's path is already an absolute URL, then
      Request.absoluteURL(...) is not called [the code before the patch is applied
      would always call Request.absoluteURL(...)].

      Notes for org.apache.struts.taglib.html.LinkTag_patch.txt
      and org.apache.struts.taglib.logic.RedirectTag_patch.txt:
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Patch causes the tag to generate an "absolute path" relative URL (taking
      into account the appropriate context path) instead of an absolute URL
      when the forward or page attribute is used. However, for the forward
      attribute, if the corresponding forward instance's path is an absolute
      URL, then the patch simply allows it to be used as-is.

      Notes for org.apache.struts.taglib.logic.ForwardTag_patch.txt
      and org.apache.struts.taglib.ForwardTag_patch.txt:
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Patch makes the forward tag use a redirecting forward instance the same
      way that the ActionServlet does – namely, if the path of the redirecting
      forward instance starts with "/", then prepend the context path;
      otherwise, use the path as-is. Note that this check is somewhat equivalent
      to calling the new RequestUtils.isAbsoluteURL(String) method, assuming that
      the purpose of this in the ActionServlet was to let absolute URLs for
      redirection be used unchanged (as opposed to prepending the context path).

      Attachments

        Activity

          People

            craigmcc Craig R. McClanahan
            stoehr.sukachevin@commerceone.com Stoehr Sukachevin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: