How to retrieve a response from server for the request sent
<p>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. </p>

<p>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.</p>

<p>The server I'm using is developed in JAVA. </p>

<p>I am using the following to send the request to server.</p>

<pre><code>NSString *post = @"username=";

post = [post stringByAppendingString:username];
post = [post stringByAppendingString:@"&amp;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];
</code></pre>

<p>And, </p>

<pre><code>- (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);

}
</code></pre>

<p>This function is never called.</p>

<p>What should i do to receive response for the request i have sent?</p>

<p>A brief collection of my queries:
Example: Login screen that validates a user in JAVA server</p>

<ol>
<li>I am sending request that i am able to see at the console of my server application.</li>
<li>I'm unable to get response for the request.</li>
<li>In which format the response data must be sent?</li>
</ol>

<p>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..</p>

<p>Any sort of help is much appreciated..</p>

<p>Thanks in advance..
Venkat</p>

<hr>

<p>Thank u guys for your quick response.. I have implemented these three methods also. But no response from server. Can you guide me the process of developing LOGIN application that communicates with a JAVA server by requests and responses? I am stuck with communicating.</p>

<p>Yeah, my server is receiving request from iphone. I am able to see the request that is sent to the server. </p>

<p>I am not able to understand how the data exchange between iphone application and JAVA server takes place. I'm a newbie to this iphone development.</p>
