Development/Java
java - URLConnection, cookie, session
linuxism
2014. 4. 17. 19: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?
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);
source - http://stackoverflow.com/questions/14979288/how-to-add-session-id-using-urlconnection