Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding login into a webpage using java code ?  RSS feed

 
Vikas Sahu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to connect a web page through java code, using HttpURLConnection api,
I am able to access its welcoe page. But this page is asking for username and password.
Can any one tell me how I can login into the website through java code. The web page is
using the post method to send request to the server.

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use basic authentication as it is described here. In that regard applets and applications work the same way.
 
Vikas Sahu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Using your sugesstion, I am able to login into the webpage but my next page is not being display.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "display" - does your Java application have a built-in browser to which you feed the HTML response which the server sends?
[ August 17, 2006: Message edited by: Ulf Dittmer ]
 
Vikas Sahu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Actually after the login i am trying to see the next page by giving the next link in the url, and trying to read InputStream from the HTTPUrlConnection object instance. But empty string is coming.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the web app set a cookie to indicate that you are logged in, or requires some URL parameter you're not passing along?

Analysing the HTTP traffic that occurs if you login through a browser will help you determine what might be missing. A tool like the LiveHTTPHeaders extension for FireFox can help greatly with this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!