Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3999

Allow XSLT result types to set response code

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.12
    • 2.3.15
    • Other
    • None

    Description

      Allow the XSLT Result type to return a custom HTTP status code.

      not sure where to put files so here is a diff of suggested changes:

      @@ -229,6 +229,9 @@
      /** Indicates the location of the xsl template. */
      private String stylesheetLocation;

      + /** Indicates the status to return in the response*/
      + private int status=200;
      +
      /** Indicates the property name patterns which should be exposed to the xml. */
      private String matchingPattern;

      @@ -271,10 +274,23 @@
      return stylesheetLocation;
      }

      + public String getStatus()

      { + return String.valueOf(status); + }

      +
      + public void setStatus(String status) {
      + try

      { + this.status = Integer.valueOf(status); + }

      catch(NumberFormatException e)

      { + throw new IllegalArgumentException("Status value not number" + e.getMessage()); + }

      + }
      +
      public String getExposedValue()

      { return exposedValue; }

      +
      public void setExposedValue(String exposedValue)

      { this.exposedValue = exposedValue; }

      @@ -328,7 +344,7 @@

      try {
      HttpServletResponse response = ServletActionContext.getResponse();
      -
      + response.setStatus(status);
      PrintWriter writer = response.getWriter();

      // Create a transformer for the stylesheet.

      Attachments

        1. XSLTResult.diff
          1 kB
          Steve Wolke
        2. WW-3999.patch
          1 kB
          Steve Wolke

        Activity

          People

            lukaszlenart Lukasz Lenart
            smwolke Steve Wolke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified