Why Server Side Programming?
Though it is technically feasible to implement almost any business logic using client side programs, logically or functionally it carries no ground when it comes to enterprise applications (e.g. banking, air ticketing, e-shopping etc.). To further explain, going by the client side programming logic; a bank having 10,000 customers would mean that each customer should have a copy of the program(s) in his or her PC which translate to 10,000 programs! In addition, there are issues like security, resource pooling, concurrent access and manipulations to the database which simply cannot be handled by client side programs. The answer to most of the issues cited above is – “Server Side Programming”. Figure-1 illustrates Server side architecture in the simplest terms.
Advantages of Server Side Programs
The list below highlights some of the important advantages of Server Side programs.
- All programs reside in one machine called the Server. Any number of remote machines (called clients) can access the server program.
- New functionalities to existing programs can be added at the server side which the clients’ can advantage without having to change anything from their side.
- Migrating to newer versions, architectures, design patterns, adding patches, switching to new databases can be done at the server side without having to bother about clients’ hardware or software capabilities.
- Issues relating to enterprise applications like resource management, concurrency, session management, security and performance are managed by service side applications.
- They are portable and possess the capability to generate dynamic and user-based content (e.g. displaying transaction information of credit card or debit card depending on user’s choice).
Types of Server Side Programs
- Active Server Pages (ASP)
- Java Servlets
- Java Server Pages (JSPs)
- Enterprise Java Beans (EJBs)
- PHP
To summarize, the objective of server side programs is to centrally manage all programs relating to a particular application (e.g. Banking, Insurance, e-shopping, etc). Clients with bare minimum requirement (e.g. Pentium II, Windows XP Professional, MS Internet Explorer and an internet connection) can experience the power and performance of a Server (e.g. IBM Mainframe, Unix Server, etc) from a remote location without having to compromise on security or speed. More importantly, server programs are not only portable but also possess the capability to generate dynamic responses based on user’s request.
Servlet
Servlet technology is used to create web application (resides at server side and generates dynamic web page).
Servet technology is robust and scalable as it uses the java language. Before Servlet, CGI (Common Gateway Interface) scripting language was used as a server-side programming language. But there were many disadvantages of this technology. We have discussed these disadvantages below.
There are many interfaces and classes in the servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest, ServletResponse etc.
What is a Servlet?
Servlet can be described in many ways, depending on the context.
- Servlet is a technology i.e. used to create web application.
- Servlet is an API that provides many interfaces and classes including documentations.
- Servlet is an interface that must be implemented for creating any servlet.
- Servlet is a class that extend the capabilities of the servers and respond to the incoming request. It can respond to any type of requests.
- Servlet is a web component that is deployed on the server to create dynamic web page.
Advantage of Servlet
There are many advantages of Servlet over CGI. The web container creates threads for handling the multiple requests to the servlet. Threads have a lot of benefits over the Processes such as they share a common memory area, lighweight, cost of communication between the threads are low. The basic benefits of servlet are as follows:
- better performance: because it creates a thread for each request not process.
- Portability: because it uses java language.
- Robust: Servlets are managed by JVM so no need to worry about momory leak, garbage collection etc.
- Secure: because it uses java language.
The basic terminology used in servlet are given below:
- HTTP
- HTTP Request Types
- Difference between Get and Post method
- Container
- Server and Difference between web server and application server
- Content Type
- Introduction of XML
- Deployment
CGI(Common Gateway Interface)
CGI technology enables the web server to call an external program and pass HTTP request information to the external program to process the request. For each request, it starts a new process.
Disadvantages of CGI
There are many problems in CGI technology:
- If number of clients increases, it takes more time for sending response.
- For each request, it starts a process and Web server is limited to start processes.
- It uses platform dependent language e.g. C, C++, perl.
YouTube Channel : CS CORNER SUNITA RAI