Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

html/java

Hi there
I am working on the following code which would enable the user to attach to a webiste/html site through the use of a socket. I do not have much experience with using a socket setup so please if you can advise me where i am missing information in the code below.

thanks
import java.io.*;
import java.net.*;
import java.util.Scanner;
 
class GetDataFromWebServer {
 
GetDataFromWebServer () throws IOException e
 
 
String address = "http://www.curl.com";
URL u = new URL (address);
URLConnection connection = u.openConnection();
 
 
final int= HTTP_PORT  = 80;
 
 
ServerSocket serverSocket = new ServerSocket (80);
 
 
InputStream ins = s.getInputStream();
 
 
OutputStream outs = s.getOutputStream();
 
 
Scanner in = new Scanner (stream);
 
 
PrintWriter out = new PrintWriterv("GET/HTTP/1.0\n\n");
 
 
String command = "GET / HTTP/1.0\n\n";
out.print(command);
 
 
out.flush ();
 
while (in.hasNextLine()) {
String line = in.nextLine();
out.println (line);
}
 
 
public static void main (String[] args) {
try {
GetDataFromWebServer g = new GetDataFromWebServer();
}
catch (Exception e) {
}
}

Open in new window

0
Sdurrani
Asked:
Sdurrani
  • 2
2 Solutions
 
Thomas4019Commented:
Are you trying to download a webpage to a file?
0
 
SdurraniAuthor Commented:
yes
0
 
SdurraniAuthor Commented:
will repost with more information as right now i want to focus on the last open question as that is Very importnat to complete
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now