• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Connect to password protected sites

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all!

I want to connect some sites with username and password. I have been looking for the solution a few days but I can't find it. I found some useful information, but i can't solve the problem.

Here is one example, the others are similar. (with other sites)

There is one forum : logintest.forumotion.com
and a topic protected by username and password : http://logintest.forumotion.net/your-first-forum-f1/testtopic-1-t2.htm

If you have an account (you're a member), you can see the topic. I have registered, i have an account. (I'm the admin in that forum, I made it)
Here is the code which I'm trying



Every time when I try it, I can't get the source of the topic. I get a login page source. What's the problem with it?
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

That page doesn't use Basic Authentication (which is what your code does), it uses form authentication. You'll need to post the account info to the proper URL, after which a cookie will probably be set which must then be sent in all subsequent page accesses.

I recommend to use a library like jWebUnit (or HtmlUnit) for programmatic access to web sites; that's generally simpler than using the URL and URLConnection classes.
 
Marton Istvan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks! I'll try it!
 
The knights of nee want a shrubbery. And a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic