?
Solved

Https Requests

Posted on 2004-10-11
2
Medium Priority
?
246 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
[X]
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
2 Comments
 
LVL 8

Accepted Solution

by:
kiranhk earned 675 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 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