Servlet - Introduction

What is Servlet?
Servlets are modules that run inside request/response-oriented servers, such as Java-enabled web servers or Servlet container (like tomcat). A Servlet container may run multiple web applications at the same time, each having multiple servlets running inside.
 
A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed by means of a request-response programming model.
 
A Java web application can contain other components than servlets. It can also contain Java Server Pages (JSP), Java Server Faces (JSF) and Web Services.
 
The basic terminology used in servlet are given below:
 
- Http
- Http Request Types
- Container
- Web Server and Application Server
- Content Type
- Introduction of XML
- Deployment
 
 
HTTP(Hyper Text Transfer Protocol) :-
 
The Hypertext Transfer Protocol is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web.
 
HTTP is designed to permit intermediate network elements to improve or enable communications between clients and servers.
 
 
HTTP Request Types:-
 
Two commonly used methods for a request-response between a client and server are: GET and POST.
GET - Requests data from a specified resource
POST - Submits data to be processed to a specified resource
 
GET :
Note that query strings (name/value pairs) is sent in the URL of a GET request:
 
/test/demo_form.asp?name1=value1&name2=value2
 
 - GET requests can be cached
 - GET requests remain in the browser history
 - GET requests can be bookmarked
 - GET requests should never be used when dealing with sensitive data
 - GET requests have length restrictions (upto 256 character)
 - GET requests should be used only to retrieve data
 
POST:
Note that query strings (name/value pairs) is sent in the HTTP message body of a POST request:
 
POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2
 
 - POST requests are never cached
 - POST requests do not remain in the browser history
 - POST requests cannot be bookmarked
 - POST requests have no restrictions on data length
 
HEAD:
Same as GET but returns only HTTP headers and no document body
 
PUT:
Uploads a representation of the specified URI
 
DELETE:
Deletes the specified resource
 
OPTIONS:
Returns the HTTP methods that the server supports
 
CONNECT:
Converts the request connection to a transparent TCP/IP tunnel
 
Container:
J2EE/Java EE applications aren't self contained. In order to be executed, they need to be deployed in a container. In other words, the container provides an execution environment on top of the JVM.
 
Also, applications rely on several APIs like JPA, EJB, servlet, JMS, JNDI, etc. The role of the EE compliant container is to provide a standard implementation of all or some of these APIs. This means you can theoretically run your application on top of any container as long as it relies on standard APIs.
 
From a technical perspective, a container is just another Java SE application with a main() method. EE applications on the other hand are a collection of services/beans/servlets/etc. The container finds these components and runs them, providing API implementations, monitoring, scalability, reliability and so on.
 
 
Web Server:
Web servers are computers that deliver (serves up) Web pages. Every Web server has an IP address and possibly a domain name. For example, if you enter the URLhttp://www.visionsdeveloper.com/index.jsp  in your browser, this sends a request to the Web server whose domain name is visionsdeveloper.com. The server then fetches the page namedindex.jsp  and sends it to your browser.
 
Any computer can be turned into a Web server by installing serversoftware and connecting the machine to the Internet. There are many Web server software applications, including public domain software from NCSA and Apache, and commercial packages fromMicrosoft, Netscape and others
 
Application Server:
An application server can be either a software framework that provides a generalized approach to creating an application-server implementation, regard to what the application functions are, or the server portion of a specific implementation instance.
 
 
Content Type:
MIME (Multipurpose Internet Mail Extensions) is an internet standard that is used to describe the contents of various files.
 
MIME types are defined in HTML by the type attribute on links,objects, and script and style tags.
 
Introduction of XML:
XML was designed to transport and store data.
HTML was designed to display data.
 
 - XML stands for EXtensible Markup Language
 - XML is a markup language much like HTML
 - XML was designed to carry data, not to display data
 - XML tags are not predefined. You must define your own tags
 - XML is designed to be self-descriptive
 - XML is a W3C Recommendation
 
Deployment:
Software deployment is all of the activities that make a software system available for use. The general deployment process consists of several interrelated activities with possible transitions between them.