You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2009/05/17 10:43:24 UTC
Bug in RequestUtils.toAbsolutePath?
Hi!
I have a dynamic image which resides in
"http://www.mydomain.com/images/Image.png" (the filename itself might
vary). In order for the image to be visible in downloaded documents,
the path must be absolute.
RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
time, except in situations where the user is on a bookmarkable page
that has parameters:
http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
In such situations the
RequestUtils.toAbsolutePath("images/Imange.png") returns:
"http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
So it assumes the last parameter value was a page... is this a stupid
user bug or a real bug?
**
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
It's available in HttpServletRequest as well.
cheers,
Steve
On 18 May 2009, at 10:37, Martin Makundi wrote:
> Ah.. so it is even worse... I need the "http://www.mycompany.com" -
> part.
>
> **
> Martin
>
> 2009/5/18 Marat Radchenko <sl...@gmail.com>:
>> http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath()
>>
>> 2009/5/18 Martin Makundi <ma...@koodaripalvelut.com>:
>>>> Just use getServletContextPath on ServletRequest.
>>>
>>> I do not want the installation path, I want the request path. The
>>> installation path is localhost:xxx and the request path is
>>> mydomain.com
>>>
>>> **
>>> Martin
>>>
>>>>
>>>> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>>>> That is my question.. whether I am stupid or someone baptized
>>>>> "toAbsoluteUrl" wrong ;)
>>>>>
>>>>> I had to devise this:
>>>>>
>>>>> public static String getRootURL() {
>>>>> StringBuffer requestURL = ((Request) ((WebRequest)
>>>>> RequestCycle
>>>>> .get().getRequest()).getHttpServletRequest()).getRequestURL();
>>>>> int cutIndex = requestURL.indexOf("/",
>>>>> requestURL.indexOf("//")+2);
>>>>> if (0 < cutIndex) {
>>>>> return requestURL.substring(0, cutIndex);
>>>>> }
>>>>> return requestURL.toString();
>>>>>
>>>>> }
>>>>>
>>>>> **
>>>>> Martin
>>>>>
>>>>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>>>>> Hmm... are you sure you want to use that method at all? It uses
>>>>>> given
>>>>>> path as relative to _current reqest path_.
>>>>>> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>>>>>> No, there is no code in RequestUtils that would care about a
>>>>>>> leading
>>>>>>> slash ... it will just result in
>>>>>>>
>>>>>>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png
>>>>>>> "
>>>>>>>
>>>>>>> Note a typo in my previous email, normally it returns:
>>>>>>>
>>>>>>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png
>>>>>>> "
>>>>>>> without the double-slash.
>>>>>>>
>>>>>>> **
>>>>>>> Martin
>>>>>>>
>>>>>>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>>>>>>
>>>>>>>> Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note
>>>>>>>> leading slash)?
>>>>>>>>
>>>>>>>> 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>>>>>>>>> Hi!
>>>>>>>>>
>>>>>>>>> I have a dynamic image which resides in
>>>>>>>>> "http://www.mydomain.com/images/Image.png" (the filename
>>>>>>>>> itself might
>>>>>>>>> vary). In order for the image to be visible in downloaded
>>>>>>>>> documents,
>>>>>>>>> the path must be absolute.
>>>>>>>>>
>>>>>>>>> RequestUtils.toAbsolutePath("images/Imange.png"); works most
>>>>>>>>> of the
>>>>>>>>> time, except in situations where the user is on a
>>>>>>>>> bookmarkable page
>>>>>>>>> that has parameters:
>>>>>>>>>
>>>>>>>>> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>>>>>>>>>
>>>>>>>>> In such situations the
>>>>>>>>> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>>>>>>>>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png
>>>>>>>>> "
>>>>>>>>>
>>>>>>>>> So it assumes the last parameter value was a page... is this
>>>>>>>>> a stupid
>>>>>>>>> user bug or a real bug?
>>>>>>>>>
>>>>>>>>> **
>>>>>>>>> Martin
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Ah.. so it is even worse... I need the "http://www.mycompany.com" -part.
**
Martin
2009/5/18 Marat Radchenko <sl...@gmail.com>:
> http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath()
>
> 2009/5/18 Martin Makundi <ma...@koodaripalvelut.com>:
>>> Just use getServletContextPath on ServletRequest.
>>
>> I do not want the installation path, I want the request path. The
>> installation path is localhost:xxx and the request path is
>> mydomain.com
>>
>> **
>> Martin
>>
>>>
>>> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>>> That is my question.. whether I am stupid or someone baptized
>>>> "toAbsoluteUrl" wrong ;)
>>>>
>>>> I had to devise this:
>>>>
>>>> public static String getRootURL() {
>>>> StringBuffer requestURL = ((Request) ((WebRequest)
>>>> RequestCycle.get().getRequest()).getHttpServletRequest()).getRequestURL();
>>>> int cutIndex = requestURL.indexOf("/", requestURL.indexOf("//")+2);
>>>> if (0 < cutIndex) {
>>>> return requestURL.substring(0, cutIndex);
>>>> }
>>>> return requestURL.toString();
>>>>
>>>> }
>>>>
>>>> **
>>>> Martin
>>>>
>>>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>>> > Hmm... are you sure you want to use that method at all? It uses given
>>>> > path as relative to _current reqest path_.
>>>> > 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>>> >> No, there is no code in RequestUtils that would care about a leading
>>>> >> slash ... it will just result in
>>>> >>
>>>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
>>>> >>
>>>> >> Note a typo in my previous email, normally it returns:
>>>> >>
>>>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
>>>> >> without the double-slash.
>>>> >>
>>>> >> **
>>>> >> Martin
>>>> >>
>>>> >> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>>> >>
>>>> >> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
>>>> >> >
>>>> >> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>>>> >> >> Hi!
>>>> >> >>
>>>> >> >> I have a dynamic image which resides in
>>>> >> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
>>>> >> >> vary). In order for the image to be visible in downloaded documents,
>>>> >> >> the path must be absolute.
>>>> >> >>
>>>> >> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
>>>> >> >> time, except in situations where the user is on a bookmarkable page
>>>> >> >> that has parameters:
>>>> >> >>
>>>> >> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>>>> >> >>
>>>> >> >> In such situations the
>>>> >> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>>>> >> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>>>> >> >>
>>>> >> >> So it assumes the last parameter value was a page... is this a stupid
>>>> >> >> user bug or a real bug?
>>>> >> >>
>>>> >> >> **
>>>> >> >> Martin
>>>> >> >>
>>>> >> >> ---------------------------------------------------------------------
>>>> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>> >> >>
>>>> >> >>
>>>> >> >
>>>> >> > ---------------------------------------------------------------------
>>>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>>>> >> >
>>>> >> >
>>>> >>
>>>> >> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>> >>
>>>> >>
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>>> >
>>>> >
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Marat Radchenko <sl...@gmail.com>.
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath()
2009/5/18 Martin Makundi <ma...@koodaripalvelut.com>:
>> Just use getServletContextPath on ServletRequest.
>
> I do not want the installation path, I want the request path. The
> installation path is localhost:xxx and the request path is
> mydomain.com
>
> **
> Martin
>
>>
>> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>> That is my question.. whether I am stupid or someone baptized
>>> "toAbsoluteUrl" wrong ;)
>>>
>>> I had to devise this:
>>>
>>> public static String getRootURL() {
>>> StringBuffer requestURL = ((Request) ((WebRequest)
>>> RequestCycle.get().getRequest()).getHttpServletRequest()).getRequestURL();
>>> int cutIndex = requestURL.indexOf("/", requestURL.indexOf("//")+2);
>>> if (0 < cutIndex) {
>>> return requestURL.substring(0, cutIndex);
>>> }
>>> return requestURL.toString();
>>>
>>> }
>>>
>>> **
>>> Martin
>>>
>>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>> > Hmm... are you sure you want to use that method at all? It uses given
>>> > path as relative to _current reqest path_.
>>> > 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>>> >> No, there is no code in RequestUtils that would care about a leading
>>> >> slash ... it will just result in
>>> >>
>>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
>>> >>
>>> >> Note a typo in my previous email, normally it returns:
>>> >>
>>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
>>> >> without the double-slash.
>>> >>
>>> >> **
>>> >> Martin
>>> >>
>>> >> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>> >>
>>> >> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
>>> >> >
>>> >> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>>> >> >> Hi!
>>> >> >>
>>> >> >> I have a dynamic image which resides in
>>> >> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
>>> >> >> vary). In order for the image to be visible in downloaded documents,
>>> >> >> the path must be absolute.
>>> >> >>
>>> >> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
>>> >> >> time, except in situations where the user is on a bookmarkable page
>>> >> >> that has parameters:
>>> >> >>
>>> >> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>>> >> >>
>>> >> >> In such situations the
>>> >> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>>> >> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>>> >> >>
>>> >> >> So it assumes the last parameter value was a page... is this a stupid
>>> >> >> user bug or a real bug?
>>> >> >>
>>> >> >> **
>>> >> >> Martin
>>> >> >>
>>> >> >> ---------------------------------------------------------------------
>>> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >> >>
>>> >> >>
>>> >> >
>>> >> > ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >> >
>>> >> >
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> Just use getServletContextPath on ServletRequest.
I do not want the installation path, I want the request path. The
installation path is localhost:xxx and the request path is
mydomain.com
**
Martin
>
> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>> That is my question.. whether I am stupid or someone baptized
>> "toAbsoluteUrl" wrong ;)
>>
>> I had to devise this:
>>
>> public static String getRootURL() {
>> StringBuffer requestURL = ((Request) ((WebRequest)
>> RequestCycle.get().getRequest()).getHttpServletRequest()).getRequestURL();
>> int cutIndex = requestURL.indexOf("/", requestURL.indexOf("//")+2);
>> if (0 < cutIndex) {
>> return requestURL.substring(0, cutIndex);
>> }
>> return requestURL.toString();
>>
>> }
>>
>> **
>> Martin
>>
>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>> > Hmm... are you sure you want to use that method at all? It uses given
>> > path as relative to _current reqest path_.
>> > 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>> >> No, there is no code in RequestUtils that would care about a leading
>> >> slash ... it will just result in
>> >>
>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
>> >>
>> >> Note a typo in my previous email, normally it returns:
>> >>
>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
>> >> without the double-slash.
>> >>
>> >> **
>> >> Martin
>> >>
>> >> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>> >>
>> >> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
>> >> >
>> >> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>> >> >> Hi!
>> >> >>
>> >> >> I have a dynamic image which resides in
>> >> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
>> >> >> vary). In order for the image to be visible in downloaded documents,
>> >> >> the path must be absolute.
>> >> >>
>> >> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
>> >> >> time, except in situations where the user is on a bookmarkable page
>> >> >> that has parameters:
>> >> >>
>> >> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>> >> >>
>> >> >> In such situations the
>> >> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>> >> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>> >> >>
>> >> >> So it assumes the last parameter value was a page... is this a stupid
>> >> >> user bug or a real bug?
>> >> >>
>> >> >> **
>> >> >> Martin
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Marat Radchenko <sl...@gmail.com>.
Just use getServletContextPath on ServletRequest.
2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
> That is my question.. whether I am stupid or someone baptized
> "toAbsoluteUrl" wrong ;)
>
> I had to devise this:
>
> public static String getRootURL() {
> StringBuffer requestURL = ((Request) ((WebRequest)
> RequestCycle.get().getRequest()).getHttpServletRequest()).getRequestURL();
> int cutIndex = requestURL.indexOf("/", requestURL.indexOf("//")+2);
> if (0 < cutIndex) {
> return requestURL.substring(0, cutIndex);
> }
> return requestURL.toString();
>
> }
>
> **
> Martin
>
> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
> > Hmm... are you sure you want to use that method at all? It uses given
> > path as relative to _current reqest path_.
> > 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
> >> No, there is no code in RequestUtils that would care about a leading
> >> slash ... it will just result in
> >>
> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
> >>
> >> Note a typo in my previous email, normally it returns:
> >>
> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
> >> without the double-slash.
> >>
> >> **
> >> Martin
> >>
> >> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
> >>
> >> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
> >> >
> >> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
> >> >> Hi!
> >> >>
> >> >> I have a dynamic image which resides in
> >> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
> >> >> vary). In order for the image to be visible in downloaded documents,
> >> >> the path must be absolute.
> >> >>
> >> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
> >> >> time, except in situations where the user is on a bookmarkable page
> >> >> that has parameters:
> >> >>
> >> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
> >> >>
> >> >> In such situations the
> >> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
> >> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
> >> >>
> >> >> So it assumes the last parameter value was a page... is this a stupid
> >> >> user bug or a real bug?
> >> >>
> >> >> **
> >> >> Martin
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
That is my question.. whether I am stupid or someone baptized
"toAbsoluteUrl" wrong ;)
I had to devise this:
public static String getRootURL() {
StringBuffer requestURL = ((Request) ((WebRequest)
RequestCycle.get().getRequest()).getHttpServletRequest()).getRequestURL();
int cutIndex = requestURL.indexOf("/", requestURL.indexOf("//")+2);
if (0 < cutIndex) {
return requestURL.substring(0, cutIndex);
}
return requestURL.toString();
}
**
Martin
2009/5/17 Marat Radchenko <sl...@gmail.com>:
> Hmm... are you sure you want to use that method at all? It uses given
> path as relative to _current reqest path_.
> 2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
>> No, there is no code in RequestUtils that would care about a leading
>> slash ... it will just result in
>>
>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
>>
>> Note a typo in my previous email, normally it returns:
>>
>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
>> without the double-slash.
>>
>> **
>> Martin
>>
>> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>>
>> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
>> >
>> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>> >> Hi!
>> >>
>> >> I have a dynamic image which resides in
>> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
>> >> vary). In order for the image to be visible in downloaded documents,
>> >> the path must be absolute.
>> >>
>> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
>> >> time, except in situations where the user is on a bookmarkable page
>> >> that has parameters:
>> >>
>> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>> >>
>> >> In such situations the
>> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>> >>
>> >> So it assumes the last parameter value was a page... is this a stupid
>> >> user bug or a real bug?
>> >>
>> >> **
>> >> Martin
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Marat Radchenko <sl...@gmail.com>.
Hmm... are you sure you want to use that method at all? It uses given
path as relative to _current reqest path_.
2009/5/17, Martin Makundi <ma...@koodaripalvelut.com>:
> No, there is no code in RequestUtils that would care about a leading
> slash ... it will just result in
>
> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
>
> Note a typo in my previous email, normally it returns:
>
> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
> without the double-slash.
>
> **
> Martin
>
> 2009/5/17 Marat Radchenko <sl...@gmail.com>:
>
> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
> >
> > 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
> >> Hi!
> >>
> >> I have a dynamic image which resides in
> >> "http://www.mydomain.com/images/Image.png" (the filename itself might
> >> vary). In order for the image to be visible in downloaded documents,
> >> the path must be absolute.
> >>
> >> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
> >> time, except in situations where the user is on a bookmarkable page
> >> that has parameters:
> >>
> >> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
> >>
> >> In such situations the
> >> RequestUtils.toAbsolutePath("images/Imange.png") returns:
> >> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
> >>
> >> So it assumes the last parameter value was a page... is this a stupid
> >> user bug or a real bug?
> >>
> >> **
> >> Martin
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
No, there is no code in RequestUtils that would care about a leading
slash ... it will just result in
"http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2//images/Image.png"
Note a typo in my previous email, normally it returns:
"http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/images/Image.png"
without the double-slash.
**
Martin
2009/5/17 Marat Radchenko <sl...@gmail.com>:
> Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
>
> 2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
>> Hi!
>>
>> I have a dynamic image which resides in
>> "http://www.mydomain.com/images/Image.png" (the filename itself might
>> vary). In order for the image to be visible in downloaded documents,
>> the path must be absolute.
>>
>> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
>> time, except in situations where the user is on a bookmarkable page
>> that has parameters:
>>
>> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>>
>> In such situations the
>> RequestUtils.toAbsolutePath("images/Imange.png") returns:
>> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>>
>> So it assumes the last parameter value was a page... is this a stupid
>> user bug or a real bug?
>>
>> **
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Bug in RequestUtils.toAbsolutePath?
Posted by Marat Radchenko <sl...@gmail.com>.
Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading slash)?
2009/5/17 Martin Makundi <ma...@koodaripalvelut.com>:
> Hi!
>
> I have a dynamic image which resides in
> "http://www.mydomain.com/images/Image.png" (the filename itself might
> vary). In order for the image to be visible in downloaded documents,
> the path must be absolute.
>
> RequestUtils.toAbsolutePath("images/Imange.png"); works most of the
> time, except in situations where the user is on a bookmarkable page
> that has parameters:
>
> http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Value2
>
> In such situations the
> RequestUtils.toAbsolutePath("images/Imange.png") returns:
> "http://www.mydomain.com/BookmarkablePage/Parameter1/Value1/Parameter2/Image.png"
>
> So it assumes the last parameter value was a page... is this a stupid
> user bug or a real bug?
>
> **
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org