I was talking bollocks (now i've tried it)
<c:set var="link" value="${fn:replace(link,'?','/')}" />
<c:set var="link" value="${fn:replace(link,'&','/')}" />
works..
Ideally in a tag file like this,, /WEB-INF/tags/cleanLink.tag
<%@ tag isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ attribute name="link" %>
<c:set var="link" value="${fn:replace(link,'?','/')}" />
<c:set var="link" value="${fn:replace(link,'&','/')}" />
${link}
..
and use the tag like this.
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:url var="mylink" value="/action.do">
<c:param name="one" value="firstval" />
<c:param name="two" value="firstval" />
<c:param name="three" value="firstval" />
</c:url>
<a href="<tags:cleanLink link="${mylink}" />">click this</a>
You may need tomcat 5 to do it..
Mark
On 5 Oct 2004, at 09:41, Mark Lowe wrote:
There's a filter that does URL rewriting already, urlrewrite ,
mod_rewrite would be okay but who wants to run mod_jk - apache as
his/her development environments.
http://tuckey.org/urlrewrite/
The only problem then is generating the links.
so rather than
<html:link page="/action.do" .. >
you'd use something like..
<c:url var="link" value="/action.do">
<c:param name="name" value="somevalue" />
.. and so on
</c:url>
this will render to
/appname/action.do?name=somevalue
so now lets say you've set a boolean called cleanURL, this means you
can switch the functionality off if you want to deactivated urlrewrite
during development. An init param in web.xml i suggest would be the
best place, but for now lets set in the page.
<c:set var="cleanURL" value="true" /'>
<c:if test="${cleanURL}">
<c:forTokens var="badChar" items="?,&" delims=",">
<c:set var="cleanLink" value="${fn:replace(link,badChar,'/'}'' />
<c:set var="link" value="${cleanLink}" />
</c:forTokens>
</c:if>
<a href="${link}">Link</a>
Once you've set urlrewrite filter up you'll want something like this.
<rule>
<from>/action.do/*/*</from>
<to type="redirect">/action.do?$1=$2</to>
</rule>
HTH Mark
On 2 Oct 2004, at 17:59, David G. Friedman wrote:
You should be able to do with in 1.2.4 with WildCard mapping,
see section 4.10 - Using Wildcards in Action Mappings.
http://struts.apache.org/userGuide/building_controller.html
Regards,
David
-----Original Message-----
From: Ben [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 02, 2004 11:53 AM
To: Struts; Tomcat
Subject: Search engine friendly URLs
Hi
Is it possible to make the URLs on my site search engine friendly? I
am using Tomcat and Struts.
I would like to turn:
http://localhost/site.do?section=books&subsection=architecture
into this:
http://localhost/do/site/books/architecture
Regards,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]