is a term referring to any specification that identifies an object on the internet. there are two types URIs--URL(Uniform Resource Locator) and Uniform Resource Name.
URL is a specification for identifying an object, such as a file, newsgroup,CGI program by indicating its exact location on the internet.
URN is a method for referencing an object without declaring the full path to the object. rather by its location, a resource is referenced by its an alias. in case the resource is removed, all there are multiple copies on different servers in different parts of the world. when a request is made for a URN, the browser could locate the nearest copy of the resource and return it. URN is not supported by most software.
format
http://host[:port]/path/resource_name[#section][?query_string]
ftp://username:password@host[:port]/path
try{
url=new URL("http://yahoo.com/index.html")
}
catch(MalformedURLException e){
}
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String nextLine = in.readLine
this return html files
absolute URL
relative URL
URL encoding:
URLs are comprised of a string of printable characters within ASCII coded character set. Any unsafe or nonprintable characters within a URL must be encoded. URL encoding involves replacing those characters with % followed by two hexadecimal digits corresponding to the character's ASCII value.
%20 is space, but it is so common, it is encoded as a single plus +
then + itself is encoded as %2B
Java includes a class to help convert resource names and other references into URL safe strings
URLEncoder.encode(string)
Web browser: is a client application that requests, receives, and displays HTML tags
web server is also called httpserver, responds to requests from a web browser by returning html,images ..also responsible for enforcing security polices, logging , cach
simple web server implementation
ServerSocket serverConnect ServerSocket(port); listen on port
HttpServer server = new HttpServer(serverConnect.accept())
CGI: common Gateway Interface
is a standard interface between an HTTP server and an application.CGI enables the Web server to generate dynamic content rather than just return static HTML files.In addition, because CGI can accept and process information submitted by the user,it can provide two way interaction between the client and the web server.
No comments:
Post a Comment