You are on page 1of 2

What is an Applet?

According to Sun "An applet is a small program that is intended not to be run on its own,
but rather to be embedded inside another application....The Applet class provides a
standard interface between applets and their environment."

Four definitions of applet:

• A small application
• A secure program that runs inside a web browser
• A subclass of java.applet.Applet
• An instance of a subclass of java.applet.Applet

URLs
A URL, short for "Uniform Resource Locator", is a way to unambiguously identify the
location of a resource on the Internet. Some typical URLs look like:

http://www.javasoft.com/

Sockets
Before data is sent across the Internet from one host to another using TCP/IP, it is split
into packets of varying but finite size called datagrams. Datagrams range in size from a
few dozen bytes to about 60,000 bytes. Anything larger than this, and often things
smaller than this, needs to be split into smaller pieces before it can be transmitted. The
advantage is that if one packet is lost, it can be retransmitted without requiring redelivery
of all other packets. Furthermore if packets arrive out of order they can be reordered at
the receiving end of the connection.

However this is all transparent to the Java programmer. The host's native networking
software transparently handles the splitting of data into packets on the sending end of a
connection, and the reassembly of packets on the receiving end. Instead, the Java
programmer is presented witha higher level abstraction called a socket. The socket
represents a reliable connection for the transmission of data between two hosts. It isolates
you from the details of packet encodings, lost and retransmitted packets, and packets that
arrive out of order.

There are four fundamental operations a socket performs. These are:

1. Connect to a remote machine


2. Send data
3. Receive data
4. Close the connection

A socket may not be connected to more than one host at a time.

Java Servlet API allows a software developer to add dynamic content to a Web server
using the Java platform. The generated content is commonly HTML, but may be other
data such as XML. Servlets are the Java counterpart to dynamic web content technologies
such as CGI, PHP or ASP. Servlets can maintain state across many server transactions by
using HTTP cookies, session variables or URL rewriting.

The Servlet API, contained in the Java package hierarchy javax.servlet, defines the
expected interactions of a web container and a servlet. A web container is essentially the
component of a web server that interacts with the servlets. The web container is
responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet
and ensuring that the URL requester has the correct access rights.

A Servlet is an object that receives requests (ServletRequest) and generates a response


(ServletResponse) based on the request. The API package javax.servlet.http defines
HTTP subclasses of the generic servlet (HttpServlet) request (HttpServletRequest) and
response (HttpServletResponse) as well as an (HttpSession) that tracks multiple requests
and responses between the web server and a client. Servlets may be packaged in a WAR
file as a Web application.

Moreover, servlets can be generated automatically by JavaServer Pages (JSP), or


alternately by template engines such as WebMacro. Often servlets are used in
conjunction with JSPs in a pattern called "Model 2", which is a flavor of the model-view-
controller pattern.

You might also like