Rasmikanta Guru
Rasmikanta Guru

Reputation: 51

how to add session id using URLConnection

I am trying to upload an image to a server using server url. For this i am using java.net api. After sending request , it is returning a response that shows session invalid. I am getting the session id from that server but unable to add it. How can i add session id using HttpURLConnection while sending request to server. Is their any way to solve this?

Upvotes: 3

Views: 12361

Answers (1)

Oleg Mikheev
Oleg Mikheev

Reputation: 17444

Session ID is stored in a cookie, in JavaEE its name is jsessionid, and you add it like that:

httpURLConnection.setRequestProperty(
    "Cookie","JSESSIONID=" + your_session_id);

Upvotes: 8

Related Questions