Search code examples
javasession-cookies

How do I take forward a session from a authenticator POST request into a GET request in JAVA?


please refer to this Java equivalent of a curl cookie statement

I have a Java code where a post request works perfectly as follows using MgntUtils library as mentioned in the above link.

here the code :

HttpClient client = new HttpClient();

client.setContentType("application/json; charset=utf-8");

client.setConnectionUrl("http://egurl/app/app1/session/login");

client.sendHttpRequest(HttpMethod.POST, "{\"username\":\"acd\",\"password\":\"pwd\",\"isPasswordEncrypted\":\"false\"}");

i need to use the same session and use it to get some data from a different URL eg. http://egurl/app/app1/param/paramgrp/1234

is there a way i can use session to get this done. i am fairly new to GET and POST in JAVA so need some help.

Thanks/


Solution

  • This can be achieved using jsoup wrapper classes. please follow this link to have a better understanding.