0
我使iphone应用程序,从iphone发布参数到JSP(服务器中的test.jsp)。以下是我的代码:得到返回结果后发送到服务器(从iphone)
NSData *postData = [@"&test=123&field=456" dataUsingEncoding:NSUTF8StringEncoding];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
// Init and set fields of the URLRequest
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"POST"];
[request setURL:[NSURL URLWithString:[NSString stringWithString:@"http://mydomain.com/test.jsp"]]];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection) {
// Return data of the request
NSData *receivedData = [[NSMutableData data] retain];
}
[request release];
但我的问题是:我无法从JSP服务器获取返回结果。 如何在JSP中设置以获取iPhone中的返回结果?并在iPhone呢?
感谢所有
我必须在我的JSP服务器中设置什么? – MartinJoo 2010-03-10 09:29:26
我对JSP一无所知,但我会假设需要某种接收消息并回复消息。 – 2010-03-10 10:05:02