You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2013/09/18 09:27:54 UTC

[jira] [Updated] (WW-4024) Support expressions for scheme attribute in s:url

     [ https://issues.apache.org/jira/browse/WW-4024?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-4024:
------------------------------

    Fix Version/s:     (was: 2.3.16)
                   2.3.17
    
> Support expressions for scheme attribute in s:url
> -------------------------------------------------
>
>                 Key: WW-4024
>                 URL: https://issues.apache.org/jira/browse/WW-4024
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Tags
>    Affects Versions: 2.3.8
>            Reporter: Octavi Ripolles-Querol
>            Priority: Minor
>             Fix For: 2.3.17
>
>         Attachments: CustomUrlRenderer.java, CustomUrlRendererV2.java, WW-3999-v1-url-tag.patch
>
>
> I open this issue as of Lukasz Lenart's comment on this Stack Overflow question: http://stackoverflow.com/q/15569532/837154 . I think it would be nice to support expressions at "scheme" attribute in "s:url" tag. The situation I faced is as follows:
> I'm developing a secure web application. This application runs on an application server behind a load balancer. The load balancer receives HTTPS traffic from the internet but forwards requests to the application server with HTTP. Responses are sent back from the application server to the load balancer with HTTP and then the load balancer forwards them to the internet with HTTPS. The sysadmins disabled the HTTPS support in the application servers because of performance reasons, so when we developers need to directly access a particular server (e.g. for troubleshooting) we need to use HTTP.
> So we have a scenario where the same application, from the point of view of the final user, is accessed both by HTTP and HTTPS, but the application itself only receives HTTP traffic. Struts2, when rendering a s:url tag, by default chooses the scheme used by the request. In this case, always HTTP, which is wrong from the point of view of the final users who access the application through the load balancer. 
> A work-around to this situation would be to support expressions in the scheme attribute of s:url, so with the following code:
> {code:xml}
> <s:url scheme="%{myScheme}" id="myUrl" action="MyAction" includeParams="none">
>    <s:param name="someParam" value="blah"/>
> </s:url>
> <s:a href="%{myUrl}">click me</s:a>
> {code}
> Struts would render either
> {code:xml}
> <a href="https://myhost.com/mywebapp/MyAction.action?someParam=blah">click me</a>
> {code}
> or
> {code:xml}
> <a href="http://myhost.com/mywebapp/MyAction.action?someParam=blah">click me</a>
> {code}
> instead of the current output:
> {code:xml}
> <a href="%{myScheme}://myhost.com/mywebapp/MyAction.action?someParam=blah">click me</a>
> {code}
> In my case, I've overcome this situation by using a custom implementation of UrlRenderer, actually a near copy-paste of ServletUrlRenderer, with the only change being the line where Struts2 sets the default value for the scheme attribute. I've set this default value to my convenience, using a value from the Value Stack.
> Thanks for taking this into consideration!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira