You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Cavacas <jo...@sapiens.com> on 2003/08/01 15:48:02 UTC

[OT] Approaches to URL Parameter masking in Struts

After reading a somewhat interesting post by Russell Beattie in which he
mentions the desire to separate the URL that a user sees from the actual
logic and data that it represents, it got me thinking about the approaches
that one can take in Struts to achieve something similar. I don't think the
way he refers to this practice is correct. I'm more used to referring to it
as URL parameter rewrite or masking. For those that don't know what I am
talking about, here's an example.

Say you have an URL like so: 

http://www.mysite.com/do/SomeAction?param1=value1&param2=value2

After doing some magic it looks like this to the user:

http://www.mysite.com/do/SomeAction/param1/value1/param2/value2

It's somewhat easy to do this if you use Apache in front of your container.
Using a module, you can mask and unmask the URL before and after it reaches
your container. It's somewhat common practice in PHP and Perl based sites
that I've seen. That's where I first learned the trick.

Why do this? Well the most common reason is to provide search engine
friendly URLs. The other more interesting reason is to hide away your
specific technology implementation from the URL. For example, the URL could
look something like this:

http://www.mysite.com/html/SomeAction/param1/value1 or even
http://www.mysite.com/SomeAction/html/param1/value1

It also has the advantage of making the URLs somewhat easier to remember, if
you don't have a lot of parameters that is. Cocoon seems to do this as
Russell mentions in his blog. The specific abstraction between the URL and
the underlying action mapping is already accomplished by using Struts.

Anyway to finally get to the point, what approaches (if any) have you taken
to do this in a Struts/J2EE specific way? Could a Servlet Filter be used?
Throwing Apache in front of your container is not the best solution as you
could be using IIS (gasp) or just serving the site from your container
directly. Russell describes his approach in his Blog
(http://www.russellbeattie.com/notebook/1003728.html careful it's friken
long) but it doesn't seem very clean to me. 

Thanks,
John






This communication is intended for the use of the individual(s) or entity it
was addressed to and may contain confidential and/or privileged information.
If the reader of this transmission is not the intended recipient, you are
hereby notified that any review, dissemination, distribution or copying of
this communication is prohibited.  If you receive this communication in
error, please notify the sender immediately and delete this communication
from your system(s) to which it was sent and/or replicated to. (c) 2003
Sapiens Americas Corp.

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