简体   繁体   中英

google app engine server reports error but on local server the code works fine

String sourceUrlString="http://maps.googleapis.com/maps/api/geocode/xml?address="+searchWord+"&sensor=true";//searchWord-parameter to be passed
Source source=new Source(new URL(sourceUrlString));

Element alpha=source.getFirstElement("location");
String beta[]=new String[100];

String lat=alpha.getContent().getFirstElement("lat").getContent().toString();
String lng=alpha.getContent().getFirstElement("lng").getContent().toString();

THE error pointed out by google app engine is in the above bold statements it says null pointer exception but on local server it returns the value and the code works fine.

wat are the possible solution to the above problem?and as of what i have come to conclusion is google app engine does not support Http request .is it true?

You need to use URL Fetch service to issue HTTP requests and receive responses: One example: import urllib2

url = "http://www.google.com/" try: result = urllib2.urlopen(url) doSomethingWithResult(result) except urllib2.URLError, e: handleError(e)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM