1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
protected void doGet(HttpServletRequest Requete, HttpServletResponse Response) throws ServletException, IOException
{
ServletOutputStream out = Response.getOutputStream();
String line;
String Host = "xxxxx.free.fr";
InetAddress Adresse = InetAddress.getByName(Host);
try
{
MySocket = new Socket(Host, 80);
} catch (UnknownHostException e)
{
out.println ("Serveur inconnu : " + Adresse.toString());
} catch (IOException e)
{
out.println ("Erreur de connexion au " + Adresse.toString()) ;
}
MyQuery = "GET xxxxx.htm HTTP/1.0\r\n";
PrintWriter out2 = new PrintWriter(new OutputStreamWriter(MySocket.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(MySocket.getInputStream()));
out2.print(MyQuery);
while((line = in.readLine()) != null)
{
out2.println(line);
}
//out2.flush();
out.println("Terminé pour "+ Adresse.toString());
//out.flush();
} |
Partager