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?
Asked
Active
Viewed 1.2k times
2

Oleg Mikheev
- 17,186
- 14
- 73
- 95

Rasmikanta Guru
- 41
- 1
- 2
- 8
-
http://stackoverflow.com/questions/1455856/cookies-turned-off-with-java-urlconnection this might help – rai.skumar Feb 20 '13 at 12:00
-
I am getting session invalid from the server as a response – Rasmikanta Guru Feb 21 '13 at 06:55
-
@mtk because cookie holds session ID – Oleg Mikheev Feb 21 '13 at 07:58
1 Answers
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