Hi,
I have a problem to use URLConnection and URLEncoder
String _url = http://www.192.168.6.1/Controller?msg=test";
URL url = new URL(_url);
URLConnection uc = url.openConnection();
uc.connect();
String source = "";
BufferedReader reader;
StringBuffer strbuf = new StringBuffer();
String line;
try {
reader = new BufferedReader(new InputStreamReader(url.openStream()));
while ((line = reader.readLine()) != null)
strbuf.append(line + "\n");
reader.close();
source = strbuf.toString();
System.out.println("output :"+source);
}catch(Exception e) {
e.printStackTrace();
System.out.println("Unable to establish connection to " + url);
}
Well, if the url like this is fine, but if my _url string is contain space
or others special character
then it failed.
I also try like this
URL url = new URL(URLEncoder.encode(_url));
and it failed.
Thanks
Regards,
Louis
ø¤°`°¤ø,¸¸¸,ø¤°`°¤ø,¸¸»«¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets