Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need JSSE to access HTTPS web page?

Status
Not open for further replies.

volcano

Programmer
Aug 29, 2000
136
HK
Hello, my java program has to access https web pages. Having gone through some java references, I find I may need to install an extra thing called JSSE to do this. Is it true? Could I make use of the current JDK classes to access https web pages? The way I access the web pages is that: URL u = new URL(" but MalformedURLException will appear...

Thank you very much!
 
Thank you for you reply!

I am not sure, but may I ask if it's true that only Applet can support HTTPS without installation of JSSE, but Java application will need JSSE. For my case, I need to access the HTTPS pages and save their contents into physical files. I am not sure again if Applet is able to write something into the local harddisk. Do you have any idea?

Thanks in advance!
 
Applets cant write to local HD unless an appropriate security.policy is set up.

As I said before, you DON'T need jsse to access https sites ...

URL url = new URL("...");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();

... will work !
 
Hi sedj, thanks for your reply again.

I have tried to write codes and test according to your hint to me. The sample code is shown below:
-------------------------------------------------

import java.net.*;
import java.io.*;

public class TEST
{
public static void main(String[] args) throws Exception
{
URL uu = new URL(" HttpURLConnection conn = (HttpURLConnection) uu.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));

String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}

---------------------------------------------------

if the URL is HTTP web page, it works well. But if I replace it to be another HTTPS web page (eg. the program will throw a MalformedURLException exception. So is my program incorrect? Do u have any idea?

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top