permaculture playing cards*
The moose likes Sockets and Internet Protocols and the fly likes Java Application using webpages for profile changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java Application using webpages for profile changes" Watch "Java Application using webpages for profile changes" New topic
Author

Java Application using webpages for profile changes

R Johnson
Greenhorn

Joined: Jan 05, 2010
Posts: 28

I am attempting to create an application that logs into a site (I provide my code for yahoo because javaranch does not seem to support GET method in their login) I'm using the overridden CookieManager I found here http://www.hccp.org/java-net-cookie-how-to.html. I tried here http://java.sun.com/docs/books/tutorial/networking/cookies/cookiemanager.html and I've spent the day looking at forums and similiar types for maybe a clue as to what I need to do. I altered the main of the program found at the bottom of this site http://www.hccp.org/java-net-cookie-how-to.html to look like this


This appears to allow me to login to yahoo but the returned html code is one saying the browser could not redirect which I understood because it's not a browser. So i tried to create another URLConnection and just cm.setCookies(conn2=url2.openConnection()); then returned the code of conn2 where url2 was set for http://my.yahoo.com. It returned the my yahoo page but not as me , but as a new user who needed to login. Then I tried to get the cookies on this new connection and resubmit with the extened cookies again to my.yahoo.com where I did get many more cookies I was still not logged in as a user.
My first cookies looked like this:

{yahoo.com={B={ expires=Tue, 16-Jan-2012 20:00:00 GMT, domain=.yahoo.com, B=fasdfashgh&b=73&s=unb, path=/}}}


My Second cookies looked like this

{yahoo.com={B={ expires=Tue, 16-Jan-2012 20:00:00 GMT, domain=.yahoo.com, B=fasdfasda&b=73&s=unb, path=/}, U_mtupes={ expires=Thu, 15-Jan-2009 19:55:22 GMT, domain=my.yahoo.com, U_mtupes=deleted, path=/}, MYTMI={ expires=Sat, 15-Jan-2011 19:55:22 GMT, domain=my.yahoo.com, path=/, MYTMI=546}, myc_s={ domain=my.yahoo.com, path=/, myc_s=d=aghafhhdshsghshsh.gfdgsgsdfgsdgs… myc={ expires=Sat, 15-Jan-2011 19:55:22 GMT, domain=my.yahoo.com, path=/, myc=d=fdasfdsafasdfdsafsa_afdasfasdfsda_&tv=unb, path=/}}}
I did change the cookies but tried to keep any formating symbols like periods and _ underscores and amperstands &... Just hoping maybe someone can tell me how to get the my.yahoo.com page through a java app.

There may be an easier way using just the original java.net.CookieManager but I tried looking at Sun api and that tutorial above and it doesn't explain in full detail how to even initiate the Manager(Store,PolicY) I can get CookieManager(null,CookiePolicy.ANY) to work but I'm pretty sure I need the store in there not to be null. Any help would be greatly appreciated
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Application using webpages for profile changes
 
Similar Threads
HttpUrlConnection: Login works only for first page
CookieManager doesn't send cookies?
Calendar() / Date() bug ???
HttpURLConnection or URLConnection to login in to sites
Why IE can not open a page, but Firefox can?