使用java程序获取页面,然后在填写后将其发送回

使用java程序获取页面,然后在填写后将其发送回,java,networking,Java,Networking,我的任务是: 编写一个java程序从服务器获取html页面,然后使用java程序填写表单,然后将表单发送回服务器 为此,我编写了以下代码: class htmlPageFetch{ public static void main(String[] args){ try{ Socket s = new Socket("127.0.0.1", 80);

我的任务是: 编写一个java程序从服务器获取html页面,然后使用java程序填写表单,然后将表单发送回服务器

为此,我编写了以下代码:

    class htmlPageFetch{
        public static void main(String[] args){
                try{
                        Socket s = new Socket("127.0.0.1", 80);
                        DataInputStream dIn = new DataInputStream(s.getInputStream());


        PrintWriter dOut = new PrintWriter(s.getOutputStream(), true);
                    dOut.println("GET /mytesting/justCheck.html HTTP/1.1\r\nHost:localhost\r\n\r\n");
                    boolean more_data = true;
                    String str;
                    while(more_data){


     str = dIn.readLine();
                                    if(str==null){
                                            //Now server has stopped sending data                                           //So now write again the inputs
//So i had written the following code but not working
    dOut.println("POST /mytesting/save.php HTTP/1.1\r\nHost:localhost\r\n\r\n");
    dOut.println("some=helloworld");
                                            more_data = false;
                                            continue;
                                    }
                                    System.out.println(str);
                            }
                    }catch(IOException e){

                    }
            }
    }
这是html文件:

        <html>
    <head>
    <title>Title goes here</title>
    </head>
    <body>
    <p>Hello world</p>
    <form action="save.php" method="post">
    Enter some thing here <input name="some"/>
    <br/>
    <input type="submit" value="Send"/>
    <input type="reset" value="Cancel"/>
    </form>
    </body>
    </html>

and the save.php just echo back the string entered.

So how to send back the filled form to the server back.

Thanks in Advance.

标题在这里
你好,世界

在这里输入一些东西
而save.php只是回显输入的字符串。 那么如何将填写好的表单发送回服务器。 提前谢谢。
我强烈建议您考虑使用JSoup(http://jsoup.org/). 它基本上是java的jquery。您可以很容易地获取输入字段

没有找到适合我的东西。因为我必须自己编写所有代码才能不使用api。我不关心任何其他信息,我只想提交表格。