[opencms-dev] Problem with getting URL of current page when exporting

Andras Balogh andras at reea.net
Tue Mar 2 11:36:00 CET 2004


Hello Geoff,

I think you have to use this:
String s=cms.getRequestContext().getUri();
where cms is CmsJspActionElement

Best wishes,
Andras.

Geoff Winkless wrote:

>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
>
>  
>





More information about the opencms-dev mailing list