Hi all..
I am developing an application that connects to a remote web server and exchanges data with the web server frequently. First screen of my application provides login screen that authenticates user.
I am able to authenticate user on the web server by sending a request to the server but unable to get response from the server to display success alert to the user on the iphone. In clear, i am not getting any response.
The server I'm using is developed in JAVA.
I am using the following to send the request to server.
NSString *post = @"username=";
post = [post stringByAppendingString:username];
post = [post stringByAppendingString:@"&password="];
post = [post stringByAppendingString:password];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"http://mysite.com/login.action?"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
And,
- (void)connectionNSURLConnection *)connection didReceiveDataNSData *)data
{
[receivedData appendData:data];
NSString *ReturnStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"In \"didReceiveData()\" : receivedData = %@",receivedData);
NSLog(@"Return String : %@", ReturnStr);
}
This function is never called.
What should i do to receive response for the request i have sent?
A brief collection of my queries: Example: Login screen that validates a user in JAVA server
- I am sending request that i am able to see at the console of my server application.
- I'm unable to get response for the request.
- In which format the response data must be sent?
Can anyone help me in getting this done by guiding me to a clear picture of data exchange between iphone application and a Java servlet..
Any sort of help is much appreciated..
Thanks in advance.. Venkat