-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

You could use HttpUtils.parseQueryString, but the entire class is
deprecated. I like your home made parser below, with a couple of tweaks:

David Wall wrote:
| Not really since I just need to process the query string portion to see
| if a given param exists or not.  I'm using a simple homegrown parser now:
|
|    public boolean isParamInUrl(String url, String paramName)
|    {
|        int pos = url.indexOf("?");
|        if ( pos > 0 )
|            url = url.substring(pos);

If there's no '?' in the URL, then you can return false right away, right?

|        String[] paramValues = url.split("&");

This uses a regular expression which is relatively slow since you
already know what you're looking for.

How about this implementation:

public boolean isParamInUrl(String url, String paramName)
{
~   return url.contains('?' + paramName + '=')
~       || url.contains('&' + paramName + '=');
}

This looks simpler, easier to read, and less error-prone. I would
venture a guess that it runs faster than your implementation, too. I
could increase the speed a bit by using StringBuilder directly instead
of allowing the compiler to write code for me, but that would make it
more difficult to read.

Enjoy,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiZy80ACgkQ9CaO5/Lv0PAHTACeOuvK34ABWpi0BWGWxs9ycrpL
PXcAoLINzsN1rVXgXG0fR+rI0M4TUk8U
=/+RK
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to