Use Socket to load a web page : JSP Socket « JSP « Java Tutorial






<%@ page contentType="text/html" import="java.io.*, java.net.*" %>

<% 
        try {
            Socket s = new Socket("www.java2s.com", 80);

            BufferedReader in = new BufferedReader(new 
                InputStreamReader(s.getInputStream()));
            PrintWriter socketOut = new PrintWriter(s.getOutputStream());

            socketOut.print("GET /index.html\n\n");
            socketOut.flush();

            String line;

            while ((line = in.readLine()) != null){
                out.println(line);
            }

        } catch (Exception e){}
%>








23.46.JSP Socket
23.46.1.Creating Client/Server Applications
23.46.2.Use Socket to load a web page