Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
How to retrieve URL information 
 

Here we are going to explain a method for retrieve all the network information for a given URL. In the given below example we use the URL class and make a object.

 

How to retrieve URL information

                         

Here we are going to explain a method for retrieve all the network information for a given URL. In the given below example we use the URL class and make a object. After creating a object we assign a new URL to it. Then we just call a getProtocol() method to retrieve the protocol, getPort() method for retrieve the port number of the URL, getHost to get the host name of that URL. Apart from all of this we can also find out the file name if we pass any file name with URL by getFile() and by toExternalForm() method is use to retreive the full name of the URL.

The given example shows all the above method in proper manner. The code of the example is as under

Here is the Code of the Example :

URLDemo.java

import  java.net.*;

public class URLDemo{
  
  public static void main(String args[])throws MalformedURLException{
    URL hp  = new  URL("http://www.javajazzup.com");
    System.out.println("Protocal:" +  hp.getProtocol());
    System.out.println("Port:" +  hp.getPort());
    System.out.println("Host:" +  hp.getHost());
    System.out.println("File:" +  hp.getFile());
    System.out.println("Ext:" + hp.toExternalForm());
  }
}

The out put of the above example is as under, where the output display all the information related with the given URL.

Here is the Output of the Example :

C:\roseindia>javac URLDemo.java

C:\roseindia>java URLDemo
Protocal:http
Port:-1
Host:www.javajazzup.com
File:
Ext:http://www.javajazzup.com

Download of this example.
 

                         

» View all related tutorials
Related Tags: c com forms server orm form network socket io sed request return opera ai for work wait to base pos

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

I am planning to develop a standalone system which will automatically authenticate the user with the user's network id. I need these stuffs to be as java part because, while accessing the URL itself the authentication process will take place by querying the database against the logged in user's network id.
1. I was able to retrieve the network id in javascript, but it was not useful, because we face performance related issue while running query in client side part (in JSPs).
Moreover i was able to retrieve network id using activexobject only, and this worked in IEs of higher version and it too should have some setting configured.
so to eliminate both the issues i need network id to be retrieved in the server side(in java code).
Please help me with the same, asap.

I hope the query i raised might be clear.
Thankyou,
awaiting for your suggessions,
Saravana Kumar

Posted by Saravana Kumar on Sunday, 02.1.09 @ 11:35am | #84375

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.