I'm using the following code to find the response status.
In my server side coding(Java Servlet), I set the response status using the following code:
My console displays,
Here is my problem:
Though I set response to 2001 at server side coding, I used to receive response status as 200 always(I'm getting the right response string).
Help me to receive response status as 2001 when the data is null.
Thanks in advance for help.
Code:
NSHTTPURLResponse* authenticationResponse = nil;
NSMutableURLRequest *authenticationRequest = [NSMutableURLRequest requestWithURL:url];
[authenticationRequest setHTTPMethod:@"POST"];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
NSData *responseData = [NSURLConnection sendSynchronousRequest:authenticationRequest returningResponse:&authenticationResponse error:&error];
NSLog(@"Response Code: %d",[authenticationResponse statusCode]);
NSLog(@"Response string: %@",responseStr);
In my server side coding(Java Servlet), I set the response status using the following code:
Code:
if ( data == null )
{
logger.log(info, "Username and password do not match for user:{0}", uName);
response.setStatus(2001);
out.write("Username and Password does not match"); //No I18N
}
else
{
response.setStatus(200);
out.write(data);
}
My console displays,
Code:
Response Code: 200
Response string: Username and Password does not match
Here is my problem:
Though I set response to 2001 at server side coding, I used to receive response status as 200 always(I'm getting the right response string).
Help me to receive response status as 2001 when the data is null.
Thanks in advance for help.