You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben <ne...@gmail.com> on 2004/10/02 17:53:12 UTC

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Search engine friendly URLs

Posted by Andrea Polci <ap...@gmail.com>.
On Sun, 3 Oct 2004 09:59:36 +1000, Ben <ne...@gmail.com> wrote:
> I would like to use Tomcat alone

In your web.xml use this mapping:

-------------------------------------
  <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/do/*</url-pattern>
  </servlet-mapping>
-------------------------------------

If you request the url "http://localhost/do/site/books/architecture"  


> 
> On Sat, 02 Oct 2004 19:37:35 -0400, Dov Rosenberg
> 
> 
> <do...@conviveon.com> wrote:
> > Use URL Rewriting with Apache. That will do what you are looking for.
> >
> >
> >
> >
> > On 10/2/04 11:53 AM, "Ben" <ne...@gmail.com> wrote:
> >
> > > 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: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > >
> >
> > --
> > Dov Rosenberg
> > Conviveon Corporation
> > 370 Centerpointe Circle, suite 1178
> > Altamonte Springs, FL 32701
> > http://www.conviveon.com
> > dov@conviveon.com
> > AOL IM: dovrosenberg
> > (407) 339-1177 x102
> > (407) 339-6704 (fax)
> > (800) 475-9890
> > (407) 310-8316 (cell)
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 



-- 
Andrea Polci

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


Re: Search engine friendly URLs

Posted by Andrea Polci <ap...@gmail.com>.
Sorry, I've sent the message wile I was still writing.

On Sun, 3 Oct 2004 09:59:36 +1000, Ben <ne...@gmail.com> wrote:
> I would like to use Tomcat alone

In your web.xml use this mapping:

-------------------------------------
 <servlet-mapping>
   <servlet-name>MyServlet</servlet-name>
   <url-pattern>/do/*</url-pattern>
 </servlet-mapping>
-------------------------------------

If you request the url "http://localhost/do/site/books/architecture"
and call the method:

req.getPathInfo()

you will get the String:

"/site/book/architecture"

Andrea

-- 
Andrea Polci

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


Re: AW: Search engine friendly URLs

Posted by Dov Rosenberg <do...@conviveon.com>.
When I suggested using Apache I implied that Apache would be on a separate
physical server. If possible even dynamic content can have static images
that can be served up using Apache. Our application tracks references to the
dynamic images that are stored in an application managed directory structure
on the filesystem. The only thing Tomcat needs to do is generate the HTML
pages, the web server handles all of the media requests.

Otherwise your Tomcat instance is handling all of the requests thru a single
network interface (unless you have multiple NICs and Ips) which will cause a
significant issue under load and makes your application much harder to scale
in a data center.

Tomcat may be "nearly" as fast as Apache at serving images, but why burden
it doing twice the work. I think the whole mod_jk thing is very poorly
implemented. I haven't tried mod_jk2 - hopefully it is more efficient and
easier to implement.



On 10/3/04 11:18 AM, "Steffen Heil" <li...@steffen-heil.de> wrote:

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

-- 
Dov Rosenberg
Conviveon Corporation
http://www.conviveon.com


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


AW: Search engine friendly URLs

Posted by Steffen Heil <li...@steffen-heil.de>.
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

Re: Search engine friendly URLs

Posted by Dov Rosenberg <do...@conviveon.com>.
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.

Short of passing parameters as session variables I don't think tomcat can do
what you are asking. The big problem with using session level variables is
that your pages can not be bookmarked. Most search engines can index dynamic
pages pretty well. Just make sure the URLs don't include any session
specific information, otherwise the search engine data is garbage



On 10/2/04 7:59 PM, "Ben" <ne...@gmail.com> wrote:

> I would like to use Tomcat alone
> 
> 
> On Sat, 02 Oct 2004 19:37:35 -0400, Dov Rosenberg
> <do...@conviveon.com> wrote:
>> Use URL Rewriting with Apache. That will do what you are looking for.
>> 
>> 
>> 
>> 
>> On 10/2/04 11:53 AM, "Ben" <ne...@gmail.com> wrote:
>> 
>>> 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: tomcat-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>> 
>> 
>> --
>> Dov Rosenberg
>> Conviveon Corporation
>> 370 Centerpointe Circle, suite 1178
>> Altamonte Springs, FL 32701
>> http://www.conviveon.com
>> dov@conviveon.com
>> AOL IM: dovrosenberg
>> (407) 339-1177 x102
>> (407) 339-6704 (fax)
>> (800) 475-9890
>> (407) 310-8316 (cell)
>> 
>> ---------------------------------------------------------------------
>> 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
> 

-- 
Dov Rosenberg
Conviveon Corporation
http://www.conviveon.com


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


Re: Search engine friendly URLs

Posted by Ben <ne...@gmail.com>.
I would like to use Tomcat alone


On Sat, 02 Oct 2004 19:37:35 -0400, Dov Rosenberg
<do...@conviveon.com> wrote:
> Use URL Rewriting with Apache. That will do what you are looking for.
> 
> 
> 
> 
> On 10/2/04 11:53 AM, "Ben" <ne...@gmail.com> wrote:
> 
> > 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: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> 
> --
> Dov Rosenberg
> Conviveon Corporation
> 370 Centerpointe Circle, suite 1178
> Altamonte Springs, FL 32701
> http://www.conviveon.com
> dov@conviveon.com
> AOL IM: dovrosenberg
> (407) 339-1177 x102
> (407) 339-6704 (fax)
> (800) 475-9890
> (407) 310-8316 (cell)
> 
> ---------------------------------------------------------------------
> 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


Re: Search engine friendly URLs

Posted by Mark Lowe <ma...@boxstuff.com>.
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:newreaders@gmail.com]
>> 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: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


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


Re: Search engine friendly URLs

Posted by Mark Lowe <ma...@boxstuff.com>.
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:newreaders@gmail.com]
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


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


RE: Search engine friendly URLs

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
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:newreaders@gmail.com]
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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


Re: Search engine friendly URLs

Posted by Dov Rosenberg <do...@conviveon.com>.
Use URL Rewriting with Apache. That will do what you are looking for.



On 10/2/04 11:53 AM, "Ben" <ne...@gmail.com> wrote:

> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 

-- 
Dov Rosenberg
Conviveon Corporation
370 Centerpointe Circle, suite 1178
Altamonte Springs, FL 32701
http://www.conviveon.com
dov@conviveon.com
AOL IM: dovrosenberg
(407) 339-1177 x102
(407) 339-6704 (fax)
(800) 475-9890
(407) 310-8316 (cell)


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