| Author |
URLConnection class
|
Pawan Komaram
Ranch Hand
Joined: Dec 08, 2009
Posts: 91
|
|
Hi,
How can I use URLConnection class to make a call to some URL as if I am calling from a specific browser (IE, Firefox,chrome...etc) and make use of the cookies that are already exist in a browser for that particular domain.
Thanks in advance!!
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
|
Check out this and this
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Pawan Komaram
Ranch Hand
Joined: Dec 08, 2009
Posts: 91
|
|
I dont want to set cookies anymore in the java code, my requirement is follows
Let's say I have opened a website from browser and logged into it, in this process the website has created some cookies in my browser, now I want to make a new request to the same website with slightly different url (like for retrieving user profile info) from java code (using URLConnection) which has to use the cookies information already present in the browser which are in the previous login action. is there a way to access those cookies in java code? or can we spoof our URLConnection that it is coming from that browser.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
I don't think that's possible. It definitely sounds like a security risk.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
It might be possible if you can read the cookies from the browser, and then submit them again. There are two big howevers though - there is no uniform way of storing cookies among browsers, and the storage format is not always open. For instance, Firefox and Chrome use an SQLite database of unknown structure (perhaps it's documented somewhere), Safari and Opera use a binary file with unknown structure. Internet Explorer uses plain text files but with some specific formatting.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Pawan Komaram
Ranch Hand
Joined: Dec 08, 2009
Posts: 91
|
|
how can I read those cookies from java, means that I want to read a particular domain cookies which are already stored in a browser where my applet is running.
In the applet I will be calling the same domain with slightly different URL to get some information based on those cookies.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You would need to find documentation about the specific browser. Like I said, it's different for all browsers, and I have no idea how they work because I simply never looked into it.
|
 |
 |
|
|
subject: URLConnection class
|
|
|