tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <mark.l...@boxstuff.com>
Subject Re: Search engine friendly URLs
Date Tue, 05 Oct 2004 22:17:01 GMT
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:28, 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. I think the original 
> question was posted on the struts group the other day and that he's 
> using html:link tags. I'd change these for jstl for 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 4 Oct 2004, at 15:04, Shapira, Yoav wrote:
>
>>
>> Hi,
>> You can also do this with one (or more, if you want, depending on the
>> exact requirements) Filters.  That prevents the need for a separate
>> servlet and any associated session overhead, so the performance 
>> argument
>> is even more moot.
>>
>> Yoav Shapira
>> Millennium Research Informatics
>>
>>
>>> -----Original Message-----
>>> From: Steffen Heil [mailto:lists@steffen-heil.de]
>>> Sent: Sunday, October 03, 2004 11:18 AM
>>> To: 'Tomcat Users List'
>>> Subject: AW: Search engine friendly URLs
>>>
>>> Hi
>>>
>>>> If you want to be able to scale your application, you need to be 
>>>> able
>> to
>>> move the static image handling out of tomcat to a separate web 
>>> server.
>>> Using
>>> Tomcat to handle both application chores and web serving chores will
>> limit
>>> the overall scalability of your system.
>>>
>>> I strongly disagree.
>>> Tomcat is nearly as fast as apache in serving images.
>>> So, yes, you can save a little time using apache, BUT remeber that 
>>> the
>>> apache slows tomcat down. You need cpu-cycles for apache, for mod_jk
>> and
>>> additionally for tomcat. Those cycles for apache and mod_jk are not
>>> nessesary, since tomcat can work standalone.
>>> So the question comes down to decide wether the overhead of handling
>> apache
>>> and mod_jk for dynamic content is smaller then the difference of 
>>> apache
>> and
>>> tomcat in serving images. I guess with current versions of tomcat the
>>> overhead to apache and mod_jk is even bigger.
>>> Hence, tomcat alone will be faster.
>>> (Please also consider, that static content will mostly be taken from
>> the
>>> browsers cache, whereas dynamic content needs to be received from
>> tomcat.
>>> That means that the time won by using apache for static content needs
>> to be
>>> a magnitude higher than the overhead of mod_jk. That's simply not the
>>> case.)
>>>
>>> Tomcat cannot do rewriting, that is correct, but it does not need to:
>>> I use url such as:
>>>  /content/pages/test.htm
>>> where content is mapped to my servlet.
>>> The parameter is simply the rest of the url.
>>>
>>> You could do:
>>>  http://localhost/site.do/books/architecture
>>> and parse the rest of the url to
>>>  section = books
>>> and
>>>  subsection = architecture
>>>
>>> Simply map site.do to your servlet.
>>>
>>> Reagrds,
>>>  Steffen
>>
>>
>>
>> This e-mail, including any attachments, is a confidential business 
>> communication, and may contain information that is confidential, 
>> proprietary and/or privileged.  This e-mail is intended only for the 
>> individual(s) to whom it is addressed, and may not be saved, copied, 
>> printed, disclosed or used by anyone else.  If you are not the(an) 
>> intended recipient, please immediately delete this e-mail from your 
>> computer system and notify the sender.  Thank you.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message