As promised, here is the code that finally did the trick for me.
The key was using the java.net.URL Object. This object does work when
compiled on the server side.
The code:
The relavant imports:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
The Function:
public Weather getWeatherInSingapore() {
System.out.println("Server Reached");
String request = "http://weather.yahooapis.com/forecastrss?
w=1062617&u=c";
Weather weatherReport = new Weather();
try {
URL url = new URL(request);
URLConnection yc = url.openConnection();
BufferedReader br = new BufferedReader(new
InputStreamReader(yc.getInputStream()));
String xml = "";
String line;
while ((line = br.readLine()) != null) {
xml = xml + line;
}
br.close();
weatherReport = this.convertYAHOOWeather(xml);
} catch (Exception e) {
e.printStackTrace();
}
return weatherReport;
}
Again:
WeatherReport is a custom object I've written myself to contain the
necessary Information
The convertYAHOOWeather is a private function that parses the XML
reply form the YAHOO RSS (Using dom4j).
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.