• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging in to a site programmatically

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
My requirement is to login a site with user name and password by using java program.Is this possible ??? if yes suggestions please...

thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends on how the login on this site is implemented. Is this a web site using some kind of HTTP authentication?
 
mano ranjan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Yes the site which iam trying to login uses https authentication and uses post method in action.any tips how should i proceed???

thanks
[ July 17, 2007: Message edited by: mano ranjan ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You still haven't provided much in the way of details. Apache provides a HTTP library that makes logging in and session management much easier.

In HTTP, Basic Authentication is a doddle, form based authentication is also pretty easy.

Anything else?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This really has nothing to do with servlets either.

Moving to our sockets and internet protocols forum.
Sorry for all the bouncing.
 
mano ranjan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i need to login a site using programmatically is it possible to do legally if yes how to do???

thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mano ranjan:
i need to login a site using programmatically is it possible to do legally if yes how to do?



Several things come to mind:
  • If this is a web app, then you can use the java.net.HttpUrlConnection class, or the Jakarta Commons HttpClient library to do this. More comfortable would be to use a package like jWebUnit, which works at the HTML level; login forms aren't different than other HTML forms.
  • Why are you concerned about the legality? Is this is a web site you're not supposed to access?
  • If this is a web site meant for people to use, then just doing the login programmatically isn't going to help much, is it? What do you hope to do with the content of whichever page gets sent after you login?

  •  
    mano ranjan
    Ranch Hand
    Posts: 102
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    HI
    Its is a site where i must login to it and read the data's from a particular
    page.Yes iam using URLConnection for this purpose but after providing the username and password by post action . iam getting the inputstream of this url
    after reading that url i still get the old login page data . but not the logged in page page.(i.e its not logged in i think).So how to login ???

    thanks
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Please post the code and the HTML login form you're trying to emulate.
     
    mano ranjan
    Ranch Hand
    Posts: 102
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    HI
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This code retrieves the login page, yet there's nothing in it that would submit the login form back to the server (and then read what the server sends back after that).

    If the web session involves more than just a page or two, it will be simpler to use a library like jWebUnit, rather than working with on the HTTP level like this.
     
    mano ranjan
    Ranch Hand
    Posts: 102
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    HI
    Is this jWebUnit is http testing tool ???
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by mano ranjan:
    Is this jWebUnit is http testing tool ???



    It is, but it can just as well be used outside of a testing context. It is very useful for accessing web sites programmatically.
     
    mano ranjan
    Ranch Hand
    Posts: 102
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi
    thanks for your reply . but iam not able to download from here

    thanks
     
    Ulf Dittmer
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The download works fine for me.
    reply
      Bookmark Topic Watch Topic
    • New Topic