开发者

Are there any samples/tutorials which tells how to call servlets on J2EE server from iPhone app?

Sorry for posting basic question but please give me your advise.

I have to write iOS application which communicates with web application deployed on Tomcat server. The web application requires client-app to call the "logon" servlet with username and password to get JSESSIONID. Once client get JSESSIONID, the web application allows to invoke other servlets. But I couldn't figure out how to manage the session to invoke these servlets.

Would you please introduce me the examples/tutorials to learn how to invoke these kind of s开发者_运维问答ervlets?

Thank you in advance.


Here's a decent example of making an http request from iOS: iOS: How to make a secure HTTPS connection to pass credentials?

There's nothing magic about making the call to a j2ee tomcat server - it's just an HTTP request, so any way you can make an HTTP request will work for you.

Maybe this one too: Can I make POST or GET requests from an iphone application?

edit: ahh, looks like this is the one you want: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html


The JSESSIONID is nothing special. If your application is set up to handle cookies coming back from your HTTP request then the JSESSIONID will come back as a cookie in the header. Otherwise you will be issued a redirect to a URL with the JSESSIONID in it. From there, if you handle cookies, the JSESSIONID will be passed automatically with each request with all of the other cookies. Otherwise you'll have to put it into the URL of each request manually.

Download the liveheaders plugin for Firefox and try hitting your servlet with the webbrowser and you can see how the JSESSIONID gets passed around. Next, turn off cookies in Firefox and you can see how it's passed around in the URL and you can see the redirect that Tomcat issues if you watch the headers in liveheaders.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜