[thelist] Server-side processing comparative anatomy.

Joe Crawford jcrawford at avencom.com
Thu Jun 7 14:21:48 CDT 2001


Here's three ways to do the same thing - encode a string so it can be
passed in a url. It's kind of neat to see how similar the
server-processed languages all are. I threw in a client-side version as
well.

<!-- in ASP, save as url.asp -->
<form action="url.asp" method="get">
<input name="x" type="text">
<br>
<% Response.write(Server.URLEncode(Request.QueryString("x"))) %>
</form>

<!-- in Cold Fusion, save as url.cfm -->
<cfparam name="x" default="">
<form action="url.cfm" method="get">
<input name="x" type="text">
<br>
<cfoutput>#URLEncodedFormat(x)#</cfoutput>
</form>

<!-- in PHP, save as url.php -->
<form action="url.php" method="get">
<input name="x" type="text">
<br>
<? echo rawurlencode($x); ?>
</form>

<!-- and for fun, a client side version in JavaScript -->
<form onsubmit="return false;">
<input name="x" type="text">
<input type="button" value="URL Encode It!"
  onclick="this.form.y.value=escape(this.form.x.value);">
<br>
<input name="y" type="text">
</form>

... sometimes the best reason to do something is for no reason at all.
:-)

	- Joe <http://artlung.com/>
--
Joe Crawford ||||||||||||||       mailto:jcrawford at avencom.com
||||||||||||||||||||||||             http://www.avencom.com
|||||||||||||||||||||||||||      Avencom: Set Your Sites Higher




More information about the thelist mailing list