You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2014/12/06 02:20:28 UTC

[tools, struts1] On an HTTPS page, link to HTTP URL includes port number :443

All,

I'm using StrutsLinkTool and I have a "forward" defined in
struts-config.xml that is a complete URL (like
"http://www.google.com/?q=foo"). In my page, I have this:

<a href="$link.forward('my-link-name')">link text</a>

The page this link is on is served via HTTPS with no port number, so of
course I'm using the default port number for TLS (:443). In the page
source, the link looks like this:

<a href="http://www.google.com:443/?q=foo">link text</a>

The link is unfollowable because the server (not actually google.com)
returns a 400 response because of the HTTP protocol being used on an
HTTPS port. :(

Is there a way to suppress the port number in this URL? I believe
[Struts]LinkTool is adding it because of the port number of the current
request.

Technically speaking, this is a URL that we can simply specify directly
in the page, but it's nice to have it configured via struts-config.xml
to have all our "forwards" defined in one place.

Thanks,
-chris




Re: [tools, struts1] On an HTTPS page, link to HTTP URL includes port number :443

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mike,

On 12/6/14 9:21 AM, Mike Kienenberger wrote:
> Glancing through this and through my own code, we were originally
> using the SecureLinkTool which extends the StrutsLinkTool.
> 
> But now I have a custom class that extends LinkTool and completely
> encodes the resulting url afterwards as we completely rewrite the url
> to a different format for a variety of other non-related reasons.
> 
> If SecureLinkTool doesn't do what you want, I'd suggest you subclass
> either SecureLinkTool or StrutsLinkTool to make it work the way you
> want.   Once you've done this, you just replace your "link" tool with
> your new class -- no other changes required in your templates or in
> the way you've been using $link.

Thanks. I'm more likely to hack and fix the original StrutsLinkTool (or
trace to the source and fix whatever that is).

For the meantime, I'll use my ugly hack because it's only used in one place.

Thanks,
-chris

> On Fri, Dec 5, 2014 at 8:20 PM, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> All,
>>
>> I'm using StrutsLinkTool and I have a "forward" defined in
>> struts-config.xml that is a complete URL (like
>> "http://www.google.com/?q=foo"). In my page, I have this:
>>
>> <a href="$link.forward('my-link-name')">link text</a>
>>
>> The page this link is on is served via HTTPS with no port number, so of
>> course I'm using the default port number for TLS (:443). In the page
>> source, the link looks like this:
>>
>> <a href="http://www.google.com:443/?q=foo">link text</a>
>>
>> The link is unfollowable because the server (not actually google.com)
>> returns a 400 response because of the HTTP protocol being used on an
>> HTTPS port. :(
>>
>> Is there a way to suppress the port number in this URL? I believe
>> [Struts]LinkTool is adding it because of the port number of the current
>> request.
>>
>> Technically speaking, this is a URL that we can simply specify directly
>> in the page, but it's nice to have it configured via struts-config.xml
>> to have all our "forwards" defined in one place.
>>
>> Thanks,
>> -chris
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 


Re: [tools, struts1] On an HTTPS page, link to HTTP URL includes port number :443

Posted by Mike Kienenberger <mk...@gmail.com>.
Glancing through this and through my own code, we were originally
using the SecureLinkTool which extends the StrutsLinkTool.

But now I have a custom class that extends LinkTool and completely
encodes the resulting url afterwards as we completely rewrite the url
to a different format for a variety of other non-related reasons.

If SecureLinkTool doesn't do what you want, I'd suggest you subclass
either SecureLinkTool or StrutsLinkTool to make it work the way you
want.   Once you've done this, you just replace your "link" tool with
your new class -- no other changes required in your templates or in
the way you've been using $link.

On Fri, Dec 5, 2014 at 8:20 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> All,
>
> I'm using StrutsLinkTool and I have a "forward" defined in
> struts-config.xml that is a complete URL (like
> "http://www.google.com/?q=foo"). In my page, I have this:
>
> <a href="$link.forward('my-link-name')">link text</a>
>
> The page this link is on is served via HTTPS with no port number, so of
> course I'm using the default port number for TLS (:443). In the page
> source, the link looks like this:
>
> <a href="http://www.google.com:443/?q=foo">link text</a>
>
> The link is unfollowable because the server (not actually google.com)
> returns a 400 response because of the HTTP protocol being used on an
> HTTPS port. :(
>
> Is there a way to suppress the port number in this URL? I believe
> [Struts]LinkTool is adding it because of the port number of the current
> request.
>
> Technically speaking, this is a URL that we can simply specify directly
> in the page, but it's nice to have it configured via struts-config.xml
> to have all our "forwards" defined in one place.
>
> Thanks,
> -chris
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: [tools, struts1] On an HTTPS page, link to HTTP URL includes port number :443

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mike,

On 12/5/14 8:23 PM, Mike Kienenberger wrote:
> I'm still using struts 1 and velocity on a project I'm actively
> working on this month.
> 
> I can take a look on Monday morning and see what we're doing.

Okay. I actually wrote this and tried to send it a few days ago but was
having SMTP issues across international borders (i.e. my V-prefixed ISP
has braindead SMTP servers, don't get me started). I finally got this
sent after returning to the US.

In the intervening days, I tried a few things that will work if
necessary. My current hack does something like this:

#set($myHref = $link.forward('my-link'))
#if('http' == $href.scheme && $href.port == '443')
#set($href = $href.port(80))
#end

<a href="$href">link text</a>

So it's doable... I was just hoping that it wouldn't require an ugly
hack like this. Fortunately, this is one of a *very* small number of
URLs that are (a) configured in struts-config.xml and (b) point to
resources external to our web application.

Thanks,
-chris

> On Fri, Dec 5, 2014 at 8:20 PM, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
>> All,
>>
>> I'm using StrutsLinkTool and I have a "forward" defined in
>> struts-config.xml that is a complete URL (like
>> "http://www.google.com/?q=foo"). In my page, I have this:
>>
>> <a href="$link.forward('my-link-name')">link text</a>
>>
>> The page this link is on is served via HTTPS with no port number, so of
>> course I'm using the default port number for TLS (:443). In the page
>> source, the link looks like this:
>>
>> <a href="http://www.google.com:443/?q=foo">link text</a>
>>
>> The link is unfollowable because the server (not actually google.com)
>> returns a 400 response because of the HTTP protocol being used on an
>> HTTPS port. :(
>>
>> Is there a way to suppress the port number in this URL? I believe
>> [Struts]LinkTool is adding it because of the port number of the current
>> request.
>>
>> Technically speaking, this is a URL that we can simply specify directly
>> in the page, but it's nice to have it configured via struts-config.xml
>> to have all our "forwards" defined in one place.
>>
>> Thanks,
>> -chris
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 


Re: [tools, struts1] On an HTTPS page, link to HTTP URL includes port number :443

Posted by Mike Kienenberger <mk...@gmail.com>.
I'm still using struts 1 and velocity on a project I'm actively
working on this month.

I can take a look on Monday morning and see what we're doing.

On Fri, Dec 5, 2014 at 8:20 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> All,
>
> I'm using StrutsLinkTool and I have a "forward" defined in
> struts-config.xml that is a complete URL (like
> "http://www.google.com/?q=foo"). In my page, I have this:
>
> <a href="$link.forward('my-link-name')">link text</a>
>
> The page this link is on is served via HTTPS with no port number, so of
> course I'm using the default port number for TLS (:443). In the page
> source, the link looks like this:
>
> <a href="http://www.google.com:443/?q=foo">link text</a>
>
> The link is unfollowable because the server (not actually google.com)
> returns a 400 response because of the HTTP protocol being used on an
> HTTPS port. :(
>
> Is there a way to suppress the port number in this URL? I believe
> [Struts]LinkTool is adding it because of the port number of the current
> request.
>
> Technically speaking, this is a URL that we can simply specify directly
> in the page, but it's nice to have it configured via struts-config.xml
> to have all our "forwards" defined in one place.
>
> Thanks,
> -chris
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org