Yes, it's running on Resin behind Apache.  I think I'm probably missing
something in my configurations somewhere.  I don't like either of the
methods I mentioned below.  Still trying to figure out the best solution.

On Fri, Jun 27, 2008 at 4:29 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:

> Which proxy are it? apache2 httpd?
>
> Matthew Hanlon wrote:
>
>> Hmm.  I on further thought, "Referer" is not the proper header to use.
>> Something more like this instead:
>>
>> public String getUrl(MyResource res) {
>>        PageParameters params = new PageParameters();
>>        params.put(Constants.MY_RESOURCE, res.getId());
>>
>>        WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get();
>>        String urn = cycle.urlFor(MyResponsePage.class, params).toString();
>>        String host =
>> cycle.getWebRequest().getHttpServletRequest().getHeader("Host");
>>        String context =
>> cycle.getWebRequest().getHttpServletRequest().getContextPath();
>>
>>        StringBuffer url = new StringBuffer();
>>        url.append("http://
>> ").append(host).append(context).append("/").append(urn);
>>
>>        return url.toString();
>>    }
>>
>> On Fri, Jun 27, 2008 at 9:58 AM, Matthew Hanlon <[EMAIL PROTECTED]>
>> wrote:
>>
>>
>>
>>> I was having a problem getting the full url of a page or resource after
>>> deploying my application behind a proxy.  I was previously doing the
>>> following:
>>>
>>> public String getUrl(MyResource res) {
>>> PageParameters params = new PageParameters();
>>> params.put(Constants.MY_RESOURCE, res.getId());
>>> WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get();
>>> return RequestUtils.toAbsolutePath(cycle.urlFor(MyResponsePage.class,
>>> params).toString());
>>>  }
>>>
>>> However, after deploying behind a proxy, I was expecting to get "
>>> http://my.domain.com/MyResourcePage/resouce/xxx"; and instead was getting
>>> "
>>> http://localhost:8080/MyResourcePage/resouce/xxx";.  So I adjusted to
>>> doing
>>> the following:
>>>
>>>  public String getUrl(MyResource res) {
>>>        PageParameters params = new PageParameters();
>>>        params.put(Constants.MY_RESOURCE, res.getId());
>>>        WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get();
>>>        String urn = cycle.urlFor(MyResponsePage.class,
>>> params).toString();
>>>        String referer =
>>> cycle.getWebRequest().getHttpServletRequest().getHeader("Referer");
>>>        String context =
>>> cycle.getWebRequest().getHttpServletRequest().getContextPath();
>>>        PrependingStringBuffer url = new PrependingStringBuffer(urn);
>>>        url.prepend(referer.substring(0, referer.indexOf(context) +
>>> context.length() + 1));
>>>        return url.toString();
>>>  }
>>>
>>> It's working, but I was curious if anyone had any input or a better
>>> method
>>> of accomplishing this.  Thanks!
>>>
>>> Regards,
>>> Matthew.
>>>
>>> --
>>> Matthew Rollins Hanlon
>>> http://squareoftwo.org
>>> _____________________
>>> Hanlon's Razor:
>>> "Never attribute to malice that which can be adequately explained by
>>> stupidity."
>>> http://wikipedia.org/wiki/Hanlon's_razor<http://wikipedia.org/wiki/Hanlon%27s_razor>
>>> <http://wikipedia.org/wiki/Hanlon%27s_razor>
>>>
>>>
>>
>>
>>
>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Matthew Rollins Hanlon
http://squareoftwo.org
_____________________
Hanlon's Razor:
"Never attribute to malice that which can be adequately explained by
stupidity."
http://wikipedia.org/wiki/Hanlon's_razor

Reply via email to