谷歌应用引擎服务器报告错误,但在本地服务器上代码工作正常

时间:2021-02-15 23:15:34
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?

wat是上述问题的可能解决方案吗?至于我得出的结论是google app引擎不支持Http请求。是真的吗?

1 个解决方案

#1


0  

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

您需要使用URL Fetch服务来发出HTTP请求并接收响应:一个示例:import urllib2

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

url =“http://www.google.com/”try:result = urllib2.urlopen(url)doSomethingWithResult(result)除了urllib2.URLError,e:handleError(e)

#1


0  

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

您需要使用URL Fetch服务来发出HTTP请求并接收响应:一个示例:import urllib2

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

url =“http://www.google.com/”try:result = urllib2.urlopen(url)doSomethingWithResult(result)除了urllib2.URLError,e:handleError(e)