Writing to a URL
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mohammed_javed
Posted On:   Friday, November 8, 2002 05:11 AM

I am able to make connection to a URL . Now i would like to write some parameters to the connected URL. The URL responds with some resources(HTML pages) which my application should be able to read. I tried using PrintWriter object to write by using : PrintWriter out = new PrintWriter(conn.getOutputStream()); [conn is the URL Connection object] but its giving java.IO.Exception I Tried to access the URL through the browser with the same parameters and It works! How can i get thru? Please help me ASAP, Thanks in advance JavedP    More>>

I am able to make connection to a URL .
Now i would like to write some parameters to the connected URL.

The URL responds with some resources(HTML pages) which my application should be able to read.

I tried using PrintWriter object to write by using :

PrintWriter out = new PrintWriter(conn.getOutputStream());
[conn is the URL Connection object]

but its giving java.IO.Exception

I Tried to access the URL through the browser with the same parameters and It works!

How can i get thru?
Please help me ASAP,

Thanks in advance
JavedP

   <<Less

Re: Writing to a URL

Posted By:   alight_Lee  
Posted On:   Saturday, November 9, 2002 10:51 AM

Maybe your parameters are some special string or have
"blank space" in your parameter string,and they should
be encoded first.
Try using URLEncoder to encode your parameters
I have some example code :



updatePath(String id,String path) {
String userID = URLEncoder.encode(id);
String filePath = URLEncoder.encode(path);

String connectionString= "111.111.111.111/test.asp?
userID="+userID+"&filePath="+filePath;

URL u = new URL(connectionString);
urlconnection.connect();
}



Does it answer your question ?
About | Sitemap | Contact