• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Login to a web forum

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create a java program that will log in to a PHP web forum, then navigate to a page that can only be accessed by a logged in user and finally printout the HTML source code for that page. I have been trying to figure out a solution to this problem to no avail. I would consider myself a novice programmer (I took some classes several years ago).

I think the problem that I'm running into has to do with handling cookies. After failing to figure this out from scratch, I came across the HTTPClient package and I have been trying to run their log in example found at HTTP Client Example however that doesn't seem to work. Can anyone point me in the right direction or give me an idea of where I am going wrong. Any insight is very appreciated as I'm very frustrated right now. Thanks.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TellTheDetails. Show us what you are trying and what is not working. We are happy to help if we know what is the problem
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd advise to use a library like HtmlUnit instead of HTTPClient; it has a much higher level API for working with web sites.
 
John Doven
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay I decided to use HTMLUnit as suggested. I'm still not getting it to print out the "hidden" URL so far. I created an example user name and password on a random forum for testing. Any advice? Thanks.

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't used HTMLUnit. But instead of


//Webpage only accessible to logged in users URL+private.php
printWebpage("http://www.honda-tech.com/private.php");



what if you try something like

 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The printWebpage method does not use HtmlUnit, so it has no idea of what happened before. You need to work with page2 to obtain the results of your logging in.
 
Get off me! Here, read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic