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

Joe Desbonnet jdesbonnet at gmail.com
Sun May 7 14:02:14 CEST 2006


I just confirmed the following code appears to enable Google Maps to
work from both workplace and live site (ie use one key if being called
from the live site and another if being called from the workplace).


<%@ page import="org.opencms.flex.*" %><%
HttpServletRequest origRequest =
CmsFlexController.getController(request).getTopRequest();
String requestURL = origRequest.getRequestURL().toString();
String key;
if (requestURL.startsWith("http://new.galway.net")) {
	// http://new.galway.net/ (live site) key
	key="ABQIAAAACiVUmU_-T-yGE8bdrmcK9xQwBSWJqanPJTPP6pyYZ67V9FhhBRQmauj1f-BLL4tbqaRRPfBNGFVkkQ";
} else {
	// http://cms.galway.net:8080/opencms/ (workplace) key
	key="ABQIAAAACiVUmU_-T-yGE8bdrmcK9xQuSwFTemYJMVNGn7SP25A-t2idOhSjb8n-YadRnPsyZICqD4XsLEHxFQ";
}
%>
(insert Google Map code and replace key parameter with 'key' defined above)



Joe.

On 5/6/06, Sebastian Himberger <sebastian.himberger at gmx.de> wrote:
> Hi Joe,
>
> just for the case you haven't got any further with this problem. Maybe
> gettings the original HttpRequest may help solving your problem. The
> request/response objects in OpenCms controlled JSPs are wrapped by an
> CmsFlexRequest and CmsFlexResponse. You can get the original
> HTTP-Request this way:
>
> <%@ page import="org.opencms.flex.*" %>
> HttpServletRequest origRequest =
> CmsFlexController.getController(request).getTopRequest();
> out.println("Flex Request: " + request.getRequestURL() + "<br/>");
> out.println("Original Request: " + origRequest.getRequestURL() + "<br/>");
>
> Also be aware that if you're using mod_proxy there is ( as far as i
> know) no way to get the complete original request. That's because a new
> one is created from the apache.
>
> I hope this helps
>
> best regards
> Sebastian
>
>



More information about the opencms-dev mailing list