• Post Reply Bookmark Topic Watch Topic
  • New Topic

URLConnection class  RSS feed

 
Pawan Komaram
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Pawan Komaram
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that's possible. It definitely sounds like a security risk.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pawan Komaram
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!