• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
post http problem in cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

post http problem in cocoa


  • Subject: post http problem in cocoa
  • From: Athahar <email@hidden>
  • Date: Sat, 2 Sep 2006 20:30:45 +0530

Hi i'm trying to build a simple addition tool, taking two numbers from the
user input in Cocoa, and processing in a server via HTTP post method.
in the server i've a java program to accept the variables from the cocoa
appln.
but my java program is not able to receive the variables.
what could be the problem with my code.

I've attached the code below.


#import "ConverterController.h"

@implementation ConverterController

- (IBAction)convert:(id)sender
{
   int num1,num2;
   num2 =[dollarField floatValue];
   num1 = [rateField floatValue];

   NSNumber *number1 = [NSNumber numberWithInt:num1];
   NSNumber *number2 = [NSNumber numberWithInt:num2];

   NSString* tempurlstring;
   NSString* URLString;
   NSString* resultString;

   NSMutableData *receivedData=nil;
   unsigned char *firstBuffer,*buffer;
   NSURLConnection* theConnection;
   int stringlen;


tempurlstring = [NSString stringWithCString:"http://<machine-name>:8080/CBuild/servlet/HelloAddition"];


NSString *inputs; NSString *tempinputs;

   tempinputs = [NSString stringWithCString:"input_1="];
   inputs = [tempinputs stringByAppendingFormat:@"%@ &input_2=%@",
number1,number2];


NSMutableURLRequest *postURLRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:tempurlstring]

cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];


[postURLRequest setHTTPMethod:@"POST"]; [postURLRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];



         NSData *data = [NSData dataWithBytes:inputs length:[inputs
length]];
           [postURLRequest setHTTPBody:data];




theConnection=[[NSURLConnection alloc] initWithRequest:postURLRequest delegate:self]; if (theConnection) { receivedData=[[NSMutableData data]retain]; } firstBuffer = [receivedData mutableBytes]; resultString = [NSString stringWithCString:firstBuffer];

   [amountField setStringValue:resultString];


} @end

thanks
Aths
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: post http problem in cocoa
      • From: Claudio Procida <email@hidden>
  • Prev by Date: Re: Open files on drag and drop (creating a droplet application)
  • Next by Date: Re: grey toolbar
  • Previous by thread: Re: grey toolbar
  • Next by thread: Re: post http problem in cocoa
  • Index(es):
    • Date
    • Thread