[opencms-dev] Problem with getting URL of current page when exporting
Geoff Winkless
opencms at geoff.dj
Tue Mar 2 11:24:02 CET 2004
Hello!
We're building a multi-lingual site and I use the following bit of jsp
to grab the current URL so that I can set links to different languages
based on the current page.
The example below shows the spanish template: basically it gets the
current URL, replaces anything with [_/]es with de and writes out the
link.
So if the URL is opencms/es/home.html then the link will be written out
as opencms/de/home.html
=========
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ page import="com.opencms.core.*,java.util.*,com.opencms.flex.jsp.*"
%>
stuff...
<%
com.opencms.flex.jsp.CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
I_CmsRequest req = cms.getCmsObject().getRequestContext().getRequest();
String uri=req.getRequestedResource();
%>
<a href="<cms:link><%=uri.replaceAll("([_/])es",
"$1de")%></cms:link>"><img src="de.gif" alt="deutsch"
title="deutsch"></a>
=========
It works fine offline but exported it goes horribly wrong: for some
reason the link created (and therefore I assume the getRequestedResource
value) is the name of the top JSP template, not the HTML page to be
requested.
I guess therefore I should be using a different mechanism to refer to
the current URL: can someone point me to it?
Or am I coming at this from completely the wrong direction?
Thanks
Geoff
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
More information about the opencms-dev
mailing list