Steve
Steve Luke wrote:Yes, you misunderstand what writing to a URL means.
When you make a URLConnection to an HTTP site, your open an HttpURLConnection and you get the OutputStream to it you are getting the OutputStream to the HTTPRequest being made to the server. The HTTPRequest isn't used to copy bytes to the page being requested, it is used to write request headers and form parameters (or data to be uploaded).
Steve
Steve Luke wrote:In that case, you are doing things correctly on the client side, you just are expecting incorrect results on the server side.
If I were using a JEE app for this, my goal would be to write a Servlet that maps to the /test2.htm URL. It would read the InputStream coming in from the client, then write a response in kind. I am guessing you should do the same with PHP, though I don't know enough about PHP to say how. Basically, read the Stream, form a response and send it. You might be better off using a Post response, not sure if that matters or not.
Then on the client side read the response from the PHP scripts and display it.
Steve
Steve Luke wrote:Forgive my ignorance, but PHP is server-side technology right?
If so, and if it has the ability to read a requests input stream, then you can write to the OutputStream in Java, and read from it in PHP. It isn't Java --> PHP --> MySQL it is Java --> HTTP --> PHP --> MySQL.
Or, if PHP can't read directly from the stream then you can format your data as a form submission. Using a GET request you would make a URL which includes the parameter data:
http://192.168.1.103/test2.htm?value1=Whatever&value2=Something%20Else
If the data is more complex then you want to format the request as a POST request, which means properly formatting the data you send through the HttpURLConnection's OutputStream. It means setting the proper headers and request mode, so a bit of a search will help you out.
Or use the HttpClient from Apache. Makes things easier.
Steve
Ulf Dittmer wrote:Some of the examples in the "URL" section might be helpful, especially e135: http://www.exampledepot.com/egs/java.net/pkg.html
i tried add after out.flush();
| Don't get me started about those stupid light bulbs. |