<?php echo "Welcome : ".$_POST["Name"]; ?>
package com.java.myapp; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class MyClass { public static void main(String[] args) { URL url; try { url = new URL("http://localhost/myphp/url.php"); String Name = "Weerachai Nukitram"; String sName = URLEncoder.encode(Name, "UTF-8"); URLConnection connection = url.openConnection(); connection.setDoOutput(true); OutputStreamWriter out = new OutputStreamWriter( connection.getOutputStream()); out.write("Name=" + sName); out.close(); BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream())); String decodedString; while ((decodedString = in.readLine()) != null) { System.out.println(decodedString); } in.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท