Solved

Https Requests

Posted on 2004-10-11
2
214 Views
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 https://server1.mycompany.com/myapp/login_page

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??

Thanks,

Tom
0
Comment
Question by:NorCal2612
2 Comments
 
LVL 8

Accepted Solution

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

 public static void main(String[] args) {

     try {

         // Create a URL object
         URL url = new URL("http://www.yahoo.com");
         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

http://www.hackdiary.com/archives/000028.html


Kiran
0
 
LVL 4

Author Comment

by:NorCal2612
ID: 12278943
Okay sweet thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 43
allswap challenge 6 79
Arrays.asList  VS  ArrayList 4 45
how to add new optional parameter to JSP 1 29
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
This video teaches viewers about errors in exception handling.

895 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

18 Experts available now in Live!

Get 1:1 Help Now