http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath()

2009/5/18 Martin Makundi <[email protected]>:
>> 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 <[email protected]>:
>>> 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 <[email protected]>:
>>>  > 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 <[email protected]>:
>>>  >> 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 <[email protected]>:
>>>  >>
>>>  >> > Maybe RequestUtils.toAbsolutePath("/images/Image.png") (note leading 
>>> slash)?
>>>  >>  >
>>>  >>  > 2009/5/17 Martin Makundi <[email protected]>:
>>>  >>  >> 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: [email protected]
>>>  >>  >> For additional commands, e-mail: [email protected]
>>>  >>  >>
>>>  >>  >>
>>>  >>  >
>>>  >>  > ---------------------------------------------------------------------
>>>  >>  > To unsubscribe, e-mail: [email protected]
>>>  >>  > For additional commands, e-mail: [email protected]
>>>  >>  >
>>>  >>  >
>>>  >>
>>>  >>  ---------------------------------------------------------------------
>>>  >>  To unsubscribe, e-mail: [email protected]
>>>  >>  For additional commands, e-mail: [email protected]
>>>  >>
>>>  >>
>>>  >
>>>  > ---------------------------------------------------------------------
>>>  > To unsubscribe, e-mail: [email protected]
>>>  > For additional commands, e-mail: [email protected]
>>>  >
>>>  >
>>>
>>>  ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: [email protected]
>>>  For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to