I have this code to parse url string such as ‘?var=val’ but when ‘search’ is just ‘var=val’ this code fails, how to make just ‘var=val’ work as well?
StringTokenizer st1 = new StringTokenizer(search, '?&;'); while(st1.hasMoreTokens()){ String st2= st1.nextToken(); int ii = st2.indexOf('='); if (ii > 0) { int ib = st2.length(); myparms.put( st2.substring(0,ii) , st2.substring(ii+1,ib) ); } }
1 Answer