Sunday, 5 August 2012

Basics of Web Application

Web Applications
In general a web application is a piece of code running at the server which facilitates a remote user connected to web server through HTTP protocol. Client (usually a web-browser) sends a request to Server, which sends back appropriate response or error message.
A web server is software which provides users, access to the services that are present on the internet. These servers can provide support for many protocols used over internet or intranet like HTTP, FTP, telnet etc.
HTTP Basics

A protocol defines the method and way of communication between two parties. There are many different protocols used by computers to communicate with each other depending on applications. 
For example when we talk to our teacher we use a certain way which is different from the way that we adopt with our fiends or parents. Similarly HTTP protocol uses various types of request-response messages.
It is a stateless protocol since there is no built-in state management b/w successive requests.
Parts of HTTP Request

Request method - it tells the server the type of action the client wants to perform.
Header fields - Optional headers can be used by client to tell server extra information about request e.g. client s/w and content type that it understands.
Body - Contains data sent by client to the server.
Parts of HTTP Response

Result Code: A numeric status code and its description.
Header Fields: Servers use these fields to tell client about server information like configurations and software etc.
Body: Data sent by server as part of response that is finally seen by the user.
HTTP Response Codes
An HTTP Response code tell the client about the state of the response i.e. whether it’s a valid response or some error has occurred etc. HTTP Response codes fall into five general categories.
  • Codes in the 100s are informational, indicating that the client should respond with some other action.
  • 100: Continue with partial request.
  • Values in the 200s signify that the request was successful.
  • 200: Means everything is fine.
  • Values in the 300s are used for files that have moved and usually include a Location header indicating the new address.
  • 300: Document requested can be found several places; they'll be listed in the returned document.
  • Values in the 400s indicate an error by the client.
  • 404: Indicates that the requested resource is not available.
  • 401: Indicates that the request requires HTTP authentication.
  • 403: Indicates that access to the requested resource has been denied.
  • Codes in the 500s signify an error by the server.
  • 503: Indicates that the HTTP server is temporarily overloaded and unable to handle the request.
Server Side Programming
Web server pages can be either static pages or dynamic pages. A static web page is a simple HTML file. When a client requests an HTML page the server simple sends back response with the required page.
While in case of dynamic web pages server executes an application which generates HTML web pages according to specific requests coming from client. These dynamically generated web pages are sent back to client with the response.

Layers and Web Application
Normally web applications are partitioned into logical layers. Each layer performs a specific functionality which should not be mixed with other layers. Layers are isolated from each other to reduce coupling between them but they provide interfaces to communicate with each other.

Presentation Layer: Provides a user interface for client to interact with application. This is the only part of application visible to client.
Business Layer: The business or service layer implements the actual business logic or functionality of the application. For example in case of online shopping systems this layer handles transaction management.
Data Layer: This layer consists of objects that represent real-world business objects such as an Order, OrderLineItem, Product, and so on.
There are several Java technologies available for web application development which includes Java Servlets, JavaServer Pages, JavaServer Faces etc.

No comments:

Post a Comment