[opencms-dev] Detecting URL in browser location bar?

Christian Steinert christian_steinert at web.de
Sat Apr 29 15:21:08 CEST 2006


Joe Desbonnet schrieb:
> I'm experimenting incorporating GoogleMaps into an OpenCms project. 
> However GoogleMaps requires you to obtain a key which is tied to a
> particular URL.
>
> When developing an OpenCms project, the URL for a page will be
> different when in the workplace and live site.  If I could detect the
> URL in the browser location bar within OpenCms then I could switch in
> the correct key depending on context.
>
> In a normal servlet environment the getRequestURL() of the HttpRequest
> object gives me this information. However as far as I can tell,
> somewhere between Apache and the OpenCms request object this
> information is lost.
>
> Does anyone know a reliable way of figuring out what URL is in the
> browser location bar for a request?
>   
Dear Joe,

The only thing that comes to my mind is using the original request 
object of the servlet request. Each JSP page has a variable "request" of 
type


    javax.servlet.http.HttpServletRequest. This is plain servlet stuff
    and also the case in Opencms.

request.getRequestUri() will give you the complete requested URL.
In earlier times there was a specific CmsRequest context, which you 
could obtain from CmsRequestContext. This has been removed since 6.0, so 
you should use the original servlet request object, that you get in your 
JSPs and pass the request object on to your beens, if that is needed.

Hth
christian
> Joe.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>   




More information about the opencms-dev mailing list