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 using a simple homegrown parser now:

   public boolean isParamInUrl(String url, String paramName)
   {
       int pos = url.indexOf("?");
       if ( pos > 0 )
           url = url.substring(pos);
       String[] paramValues = url.split("&");
       if ( paramValues == null )
           return false;
for( String paramValue : paramValues )
       {
           String[] paramAndValue = paramValue.split("=");
           if ( paramAndValue == null || paramAndValue.length != 2 )
               return false;
           if ( paramAndValue[0].equals(paramName) )
               return true;
       }
       return false;
   }

The concern is whether this is valid should the URL have complex params and such based on encoding schemes. I mean, it just splits the url query string into an array of param-values '&', and then splits that by '=' without concern for any encoding.

David



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