0

I seek some help from the Struts people.

We have an action that redirects to various external and full address URLs, based on a small algorithm. Depending on input the proper URL is chosen. It is implemented as shown in this post: https://stackoverflow.com/a/179251/3541538

It is working fine so far, but recently we hit a case where one of the redirection URLs contains multiple # chars. It looks like a unique case and probably such URLs are not even valid(?). The result is that Struts treat the URL as relative (I assume that it fails to validate it as a proper URL) and the final destination is a concatenation of Struts server address and remote URL, instead of just the last.

Any idea how can I work around this problem? Can I somehow disable validation or intercept the process? Ideally for that action only? Please don't waste any time on why that URL has multiple # chars, that's not going to change.

We use Struts 2.3.24.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Stelios
  • 29
  • 1
  • 7
  • maybe you just need to escape it: https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html – Austin_Anderson Jul 18 '17 at 14:01
  • Create your own result w/o validation and use it. – Aleksandr M Jul 18 '17 at 15:57
  • "Struts treat", that's it. – Roman C Jul 18 '17 at 21:53
  • @Austin_Anderson yes I tried that, so the destination address ends up with %23 instead of #, which is not what I wanted. – Stelios Jul 19 '17 at 14:27
  • 1
    @AleksandrM that was it! Many thanks! I made a custom result that reads my url parameter from StackValue and redirects to it without parsing it to a URL object. I was based on this page http://skillshared.blogspot.gr/2008/12/creating-custom-result-type-struts-2.html. How can I credit you the answer? Do you want to write an answer? – Stelios Jul 19 '17 at 14:29
  • @Stelios It was only a suggestion. Glad it helped you. :) You can answer yourself with some code snippet and accept it. – Aleksandr M Jul 19 '17 at 17:18

0 Answers0