Skip to main content

http query in java eclipse

No replies
chahinerue6
Offline
Joined: 2012-02-08
Points: 0

hello evry bady i woud like to your presented my problem

i woud lik send e-mail withe java eclipse form the mail of my institute I describing my staps :

friste step:i install http analyser after that i set this adress in my browser mail.ens-kouba.dz after set this adress I Deriger to this address to this adress is http://mail.ens-kouba.dz/src/login.php

second step: i open eclipse and i set this code

package sendMail;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class MainMail {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String str;
String cookie = null;
InetAddress adr= InetAddress.getByName("mail.ens-kouba.dz");/*entre= in, sortie=out*/
Socket cs=new Socket(adr,80);
System.out.println("Comunication Avec Le Serveur Cree ");/*the comunication wit server is etablished */
BufferedReader entre=new BufferedReader(new InputStreamReader(cs.getInputStream()));
PrintWriter sorti=new PrintWriter(new BufferedWriter(new OutputStreamWriter(cs.getOutputStream())),true);
sorti.println("GET /src/login.php HTTP/1.1\r");
sorti.println("Host:mail.ens-kouba.dz \r");
while((str=entre.readLine())!=null){System.out.println(str);}
}

}

after compiling this code i recive this message HTTP/1.1 400 Bad Request i woud like I want to know my problem or my mistake and thanks