Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With basic Java SE API you can use <a href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html" rel="noreferrer"><code>java.net.URLConnection</code></a> to fire a HTTP request. A basic example of firing a <code>GET</code> request can be found in <a href="http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html" rel="noreferrer">Sun tutorial on the subject</a>. A <code>POST</code> request isn't much different, you instead just need to set <a href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#setDoOutput%28boolean%29" rel="noreferrer"><code>URLConnection#setDoOutput()</code></a> to <code>true</code> and write the query string to <a href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#getOutputStream%28%29" rel="noreferrer"><code>URLConnection#getOutputStream()</code></a> instead of in URL.</p> <p>Note that it's "lazily executed", the request will only be fired if you actually obtain the response stream by <a href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#getInputStream%28%29" rel="noreferrer"><code>URLConnection#getInputStream()</code></a>, even though you don't need it.</p> <p>If you want less verbose code and/or more control over the request, then I can recommend to use <a href="http://hc.apache.org/" rel="noreferrer">Apache Commons HttpComponents Client</a>.</p> <p>The PHP program in turn can just be written the usual way. Get request parameters by <code>$_GET</code>, <code>$_POST</code> and so on and <code>echo</code> the response. Nothing special needs to be done here. You may however consider to use an more easy parseable response format, such as XML or JSON.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload