Https Requests

Posted on 2004-10-11
Last Modified: 2010-03-31
Hi all,

I'm trying to write a small java app that will take a url as a parameter and return the status code for that web page.

i.e. GetStatusCode

returns: 200 OK

or something like that

Can anybody show me a small example using the URL classes please?  is there a way to use certificates??


Question by:NorCal2612

Accepted Solution

kiranhk earned 225 total points
ID: 12278805
You can use the following code

 public static void main(String[] args) {

     try {

         // Create a URL object
         URL url = new URL("");
         URLConnection urlconn = url.openConnection();
         HttpURLConnection conn = (HttpURLConnection)urlconn;
         System.out.println("Code is " + conn.getResponseCode());

hope this code helps.

Also you can check out the following


Author Comment

ID: 12278943
Okay sweet thanks!

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
word0 challenge 4 54
wordcount challenge 11 78
micro services vs rest web services 16 53
Problem to start Neon 20 54
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now