You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Zhe Sun <Zh...@obs-gyn.ox.ac.uk> on 2006/10/23 17:41:46 UTC

invalid usi again with special character "^"

Hi all,

I trying to use the httpclient to retrieve some stock quote output, but
it seems that the URI does not like the character "^". Not sure how to
tackle it. Any help would be appreciated.

.....  
       StringBuffer url = new
StringBuffer("http://quote.yahoo.com/download/javasoft.beans?symbols=");
        url = url.append("^IXIC");
        url.append("&format=sl1d1t1c1ohgvbap");
..... 

The runtime error was,

Invalid uri
'http://quote.yahoo.com/download/javasoft.beans?symbols=^IXIC&format
=sl1d1t1c1ohgvbap': Invalid query:
java.lang.IllegalArgumentException: Invalid uri
'http://quote.yahoo.com/download
/javasoft.beans?symbols=^IXIC&format=sl1d1t1c1ohgvbap': Invalid query
        at org.apache.commons.httpclient.HttpMethodBase.<init>(Unknown
Source)
        at
org.apache.commons.httpclient.methods.GetMethod.<init>(Unknown Source
)

Thanks,

Zhe


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: invalid usi again with special character "^"

Posted by Julius Davies <ju...@gmail.com>.
Try URL-Encoding that character.  You just use "%" + "hex value of character
in ascii table".  For example, the space character becomes "%20".  In your
case I think you want to use "%5E" instead of "^".

http://en.wikipedia.org/wiki/Percent-encoding

yours,

Julius Davies

http://juliusdavies.ca/


On 10/23/06, Zhe Sun <Zh...@obs-gyn.ox.ac.uk> wrote:
>
> Hi all,
>
> I trying to use the httpclient to retrieve some stock quote output, but
> it seems that the URI does not like the character "^". Not sure how to
> tackle it. Any help would be appreciated.
>
> .....
>        StringBuffer url = new
> StringBuffer("http://quote.yahoo.com/download/javasoft.beans?symbols=");
>         url = url.append("^IXIC");
>         url.append("&format=sl1d1t1c1ohgvbap");
> .....
>
> The runtime error was,
>
> Invalid uri
> 'http://quote.yahoo.com/download/javasoft.beans?symbols=^IXIC&format
> =sl1d1t1c1ohgvbap': Invalid query:
> java.lang.IllegalArgumentException: Invalid uri
> 'http://quote.yahoo.com/download
> /javasoft.beans?symbols=^IXIC&format=sl1d1t1c1ohgvbap': Invalid query
>         at org.apache.commons.httpclient.HttpMethodBase.<init>(Unknown
> Source)
>         at
> org.apache.commons.httpclient.methods.GetMethod.<init>(Unknown Source
> )
>
> Thanks,
>
> Zhe
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>