Thread: Resolved HTTP request
View Single Post
Old 09-21-2012, 11:43 PM   PM User | #3
Scriptr
Regular Coder

 
Join Date: Oct 2011
Posts: 106
Thanks: 12
Thanked 0 Times in 0 Posts
Scriptr is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
Assuming you've properly read it and you have a valid structure for the html, and the JS doesn't exist, the only thing I can think of is that an IFrame is in use.
If it terminates at the point of the div, I'd say you haven't completed the read.
This is the source code for one of the pages:
Code:
<html>
<head>
<title>sustainable development</title>
<link rel="Stylesheet" href="../../../activityshared/code/glossary.css">
</head>
<body class=defBody>

<span class=defTerm>sustainable development</span>

<span class=defText>
The long-term prosperity of human societies and the ecosystems that support them
</span>

</body>
</html>
All pages are identical, save for text content

This is the code that is read:
Code:
<head>
<title>sustainable development</title>
<link rel="Stylesheet" href="../../../activityshared/code/glossary.css">
</head>
<body class=defBody>

<span class=defTerm>sustainable development</span>

<span class=defText>
</span>

</body>
Notice, the missing HTML tags and the defText tag being empty.

This is the code for the reader:
Code:
public void get(URL u) throws IOException{
		URLConnection con = u.openConnection();
		con.connect();
		BufferedReader c = new BufferedReader(new InputStreamReader(con.getInputStream()));
		System.out.println(u);
		String s = "";
		
		while(c.readLine() != null){
			s += c.readLine() + "\n";
		}
		System.out.println(s);
		c.close();
	}
Lastly, allow me to apologize for failing to include this in the original post.

Edit: I am unfamiliar with web sockets; I was skipping a line, as does not happen with a Scanner (which uses InputStream.hasNext()), and on a hunch I replaced the reader code with this:
Code:
String s = "";
		String sub;
		while((sub = c.readLine()) != null){
			s += sub + "\n";
		}
and all works perfectly.

Last edited by Scriptr; 09-21-2012 at 11:49 PM..
Scriptr is offline   Reply With Quote