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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate insert example 13 39
how to see all occupied ports on windows 10 laptop 15 84
Java Eclipse Loop 3 31
learn programming 8 72
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 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