[opencms-dev] Problem with getting URL of current page when exporting
Alexander Kandzior
alex at opencms.org
Tue Mar 2 11:39:02 CET 2004
Use
cms.getCmsObject().getRequestContext().getUri()
instead of
cms.getCmsObject().getRequestContext().getRequest().getRequestedResource()
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com
> -----Original Message-----
> From: opencms-dev-admin at opencms.org
> [mailto:opencms-dev-admin at opencms.org] On Behalf Of Geoff Winkless
> Sent: Tuesday, March 02, 2004 11:23 AM
> 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
>
>
More information about the opencms-dev
mailing list