[opencms-dev] Problem with getting URL of current page when exporting
Olli Aro
olli_aro at yahoo.co.uk
Tue Mar 2 11:37:01 CET 2004
The code I have used for similar purposes in past is:
cms.getRequestContext().getUri();
Regards,
Olli
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Geoff Winkless
Sent: 02 March 2004 10:23
To: opencms-dev at opencms.org
Subject: [opencms-dev] Problem with getting URL of current page when
exporting
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
______________________________________________________________________
_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://mail.opencms.org/mailman/listinfo/opencms-dev
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.594 / Virus Database: 377 - Release Date: 24/02/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.594 / Virus Database: 377 - Release Date: 24/02/2004
More information about the opencms-dev
mailing list