<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[JAVA] Come chiamo una apgina php da Java???]]></title><description><![CDATA[<p dir="auto">We......<br />
ho un idea da mettere in pratica....premetto che di JAVA capisco poco, quindi se rispondete siate moooolto chiari....</p>
<p dir="auto">Come posso chiamare una pagina PHP da JAVA?????</p>
]]></description><link>https://dev.connect.gt/topic/67640/java-come-chiamo-una-apgina-php-da-java</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 03:33:20 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/67640.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Apr 2008 12:17:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [JAVA] Come chiamo una apgina php da Java??? on Wed, 16 Apr 2008 09:58:57 GMT]]></title><description><![CDATA[<p dir="auto">Chiamare intendi cioè scaricare il contenuto? Se è questo, prova questo script preso in rete:</p>
<pre><code>// This example is from _Java Examples in a Nutshell_. (http://www.oreilly.com)
// Copyright (c) 1997 by David Flanagan
// This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for non-commercial purposes.
// For any commercial use, see http://www.davidflanagan.com/javaexamples

import java.io.*;
import java.net.*;

/**
 * This program connects to a Web server and downloads the specified URL
 * from it.  It uses the HTTP protocol directly.
 **/
public class HttpClient {
  public static void main(String[] args) {
    try {
      // Check the arguments
      if ((args.length != 1) &amp;&amp; (args.length != 2))
        throw new IllegalArgumentException("Wrong number of arguments");
      
      // Get an output stream to write the URL contents to
      OutputStream to_file;
      if (args.length == 2) to_file = new FileOutputStream(args[1]);
      else to_file = System.out;
      
      // Now use the URL class to parse the user-specified URL into
      // its various parts: protocol, host, port, filename.  Check the protocol
      URL url = new URL(args[0]);
      String protocol = url.getProtocol();
      if (!protocol.equals("http"))
        throw new IllegalArgumentException("URL must use 'http:' protocol");
      String host = url.getHost();
      int port = url.getPort();
      if (port == -1) port = 80;  // if no port, use the default HTTP port
      String filename = url.getFile();
      // Open a network socket connection to the specified host and port
      Socket socket = new Socket(host, port);
      // Get input and output streams for the socket
      InputStream from_server = socket.getInputStream();
      PrintWriter to_server = 
        new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
      
      // Send the HTTP GET command to the Web server, specifying the file.
      // This uses an old and very simple version of the HTTP protocol
      to_server.println("GET " + filename);
      to_server.flush();  // Send it right now!
      
      // Now read the server's response, and write it to the file
      byte[] buffer = new byte[4096];
      int bytes_read;
      while((bytes_read = from_server.read(buffer)) != -1)
        to_file.write(buffer, 0, bytes_read);
      
      // When the server closes the connection, we close our stuff
      socket.close();
      to_file.close();
    }
    catch (Exception e) {    // Report any errors that arise
      System.err.println(e);
      System.err.println("Usage: java HttpClient &lt;URL&gt; [&lt;filename&gt;]");
    }
  }
}
</code></pre>
]]></description><link>https://dev.connect.gt/post/699794</link><guid isPermaLink="true">https://dev.connect.gt/post/699794</guid><dc:creator><![CDATA[cali1981]]></dc:creator><pubDate>Wed, 16 Apr 2008 09:58:57 GMT</pubDate></item></channel></rss>