-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
Thanks for the code idea. I like what you wrote.
If there's no '?' in the URL, then you can return false right away,
right?
Indeed!
public boolean isParamInUrl(String url, String paramName)
{
~ return url.contains('?' + paramName + '=')
~ || url.contains('' + paramName + '=');
}
- Original Message -
From: David Wall [EMAIL PROTECTED]
To: Tomcat Users List users@tomcat.apache.org
Sent: Wednesday, August 06, 2008 1:17 AM
Subject: Parsing a URL to see if a param exists
Is there an API call to parse an URL I have as a String so that I can
determine if a given
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Johnny,
Johnny Kewl wrote:
| Dave this is how I do it...
|
|Enumeration paramNames = request.getParameterNames();
Go back and read the OP: he says that he's got a String and he wants to
treat it as a URL and check for parameters. He's
Is there an API call to parse an URL I have as a String so that I can
determine if a given param exists?
I know that when processing from Tomcat, I can do
request.getParameterValues() for the URL of my servlet, but I'd like to
know if the URL used to arrive at my page includes a given
--- On Tue, 8/5/08, David Wall [EMAIL PROTECTED] wrote:
From: David Wall [EMAIL PROTECTED]
Subject: Parsing a URL to see if a param exists
To: Tomcat Users List users@tomcat.apache.org
Date: Tuesday, August 5, 2008, 7:17 PM
Is there an API call to parse an URL I have as a String so
that I
http://java.sun.com/docs/books/tutorial/networking/urls/urlInfo.html
It breaks down every component of the url (protocol, domain name, etc). Is
that what you're looking for?
Not really since I just need to process the query string portion to see
if a given param exists or not. I'm
--- On Tue, 8/5/08, David Wall [EMAIL PROTECTED] wrote:
From: David Wall [EMAIL PROTECTED]
Subject: Re: Parsing a URL to see if a param exists
To: Tomcat Users List users@tomcat.apache.org
Date: Tuesday, August 5, 2008, 7:50 PM
if ( pos 0 )
url = url.substring(pos);
Found a bug in that this should be pos+1 to remove the ?.
if ( paramAndValue[0].equals(paramName) )
return true;
We're also doing a URLDecoder.decode on the paramAndValue[0] in case the
param