2

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?

Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95
Rasmikanta Guru
  • 41
  • 1
  • 2
  • 8

1 Answers1

7

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);
Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95