How do we perform multiple posts while maintaining the same session in a HttpsUrlConnection ( I am setting Cookie Header etc......but how do i maintain the same sessionKey, master secret etc across multiple posts)

To be more specific, the application should do the following
1)Connect to a remote server and extract info like session ID from the repose sent by the remote server.
2)Using this information, make another post to the same server (in the same session) to carry out some transactions

In step 2 I am facing some issues (The server is able to recognize the session,but unable to recognize data sent from the client, probably because the data should be encrypted with some key etc....)my question is how do i do this

ie...Keep the session key,certificates etc sent by the server in the first response and reuse it in the next post
I have been stuck with this issue for quite some time now and any guidance
(or a working code snippet )would be greatly appreciated