aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Working with HttpsURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Working with HttpsURLConnection " Watch "Working with HttpsURLConnection " New topic

Working with HttpsURLConnection

Cian Karthik

Joined: May 10, 2010
Posts: 3

Im using the code below to connect to a https server from java .
It validates the username and password but it doesnt redirect or goto the homepage when the inputstream is read
DataInputStream input = new DataInputStream( connection.getInputStream() );

always has the same html code from the login page even after the login has been successful .(I was expecting the html page of the user's "home").

I tried opening the connection to a new url(the actual servlet running home page of the user) but it didnt go through..(It again gave back the html code of the login page)

Could you please help me figure out a way to navigate through the website.
From login page to home page to page 2 etc using java https ?

Please find the source code below.
Greatly appreciate the help.


Source code:

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61981

"Jughead Jones", please check your private messages for an important administrative matter.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor

Joined: Oct 27, 2005
Posts: 19848

And please UseCodeTags. Your code is not readable in its current form. You can add them by pressing the edit button. Don't forget to keep your original indentation; unindented code is just as unreadable as the current form.

How To Ask Questions How To Answer Questions
Cian Karthik

Joined: May 10, 2010
Posts: 3
Sorry about that..
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42952
If this was my problem I'd use a library like HtmlUnit (or jWebUnit) which takes care of all the HTTP details.
Cian Karthik

Joined: May 10, 2010
Posts: 3
Thanks for the suggestion , tried using jwebunit . It worked well.
It is sorta covered in the JavaRanch Style Guide.
subject: Working with HttpsURLConnection