Friday, 8 September 2017

How to Create alerts in Splunk


The Steps include:


  • Open Search page in Search and Reporting Page.
  • Enter your query for which alerts need to be triggered.for example:
         index = os_web sourcetype = custom-prod-up-ext serviceName=SHARP response=failure                  feature=PCI_DE_TOKENIZATION 
  • Select Save as ---->Alert



  • Next Specify Setting,Triggered Condition,Triggered Action.


  • Select Save.

Enjoy Learning.

Tuesday, 29 August 2017

Java program to check unique number


Sample Program:-


 import java.util.*;  
 import java.io.*;  
 /**  
  * Created by Dixit on 29-08-2017.  
  */  
 public class IsUniqueNumber {  
   public static boolean  
   isUniqueUsingHash(String word)  
   {char[] chars = word.toCharArray();  
     Set<Character> set = new HashSet<Character>();  
     for (char c : chars)  
       if (set.contains(c))  
         return false;  
       else {  
         set.add(c);  
       }  
     return true;  
   }  
   public static boolean  
   isUniqueUsingSort(String word)  
   {char[] chars = word.toCharArray();  
     if (chars.length <= 1)  
       return true;  
     Arrays.sort(chars);  
     char temp = chars[0];  
     for (int i = 1; i < chars.length; i++)  
     {if (chars[i] == temp)  
       return false;  
       temp = chars[i];  
     }  
     return true;  
   }  
   public static void main(String[] args)  
       throws IOException  
   {  
     System.out.println(isUniqueUsingHash("1234")? "Unique" : "Not Unique");  
         System.out.println(isUniqueUsingSort("123")? "Unique" : "NotUnique");  
   }  
 }  


Enjoy Coding

Sunday, 20 August 2017

Interesting facts of Java


Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]).
The latest release of the Java Standard Edition is Java SE 8. With the advancement of Java and its widespread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications.
The new J2 versions were renamed as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere.
Java is:
  • Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
  • Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.
  • Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master.
  • Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.
  • Architectural-neutral: Java compiler generates an architecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence of Java runtime system.
  • Portable: Being architectural-neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler in Java is written in ANSI C with a clean portability boundary which is a POSIX subset.
  • Robust: Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
  • Multithreaded: With Java's multithreaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
  • Interpreted: Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.
  • High Performance: With the use of Just-In-Time compilers, Java enables high performance.
  • Distributed: Java is designed for the distributed environment of the internet.
  • Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

Enjoy Learning.

Monday, 26 June 2017

WHAT TO CHOOSE for Android Game Development:- canvas or OpenGL or LibGDX or Game Engines!!

Android Game Development - WHAT TO CHOOSE

Canvas or OpenGL or LibGDX or Game Engines!!


Developing games on android is not straight forward. You need to be very specific about what you are going to develop, what are the content of it and what are the requirement for it. Game can be developed from all these but everyone has its own limitation.  

As I am a java and android developer and developed some games in java and android with simple logic(Graphics lib. for java and Canvas for android) I had concluded some points.
  • If graphics are heavy than your game FPS may jitter even though you have proper architecture, but can be solved from accurate and efficient algorithm.
  • Rendering too much graphics can be tedious task.
  • There should be proper architecture of everything.
  • Efficient and best algorithm should be there.
  • Application manageability depends on how you develop it.


Canvas


It is a predefined class in android sdk. Android application can draw things on screen using this class.

java.lang.Object 
   ↳android.graphics.Canvas

means Object class is the parent class of canvas class. This class hold the "draw" calls. It can draw anything like rectangle, circle, bitmap image, etc. To draw anything some basic components is needed which are mentioned below:-
  • Paint object(to give color and style to drawing)
  • Bitmap to hold the pixels
  • Canvas to receive draw calls(drawing on Bitmap)
  • Drawing primitive(path, text, etc.)
How to use it please check android developer documentation.

OpenGL


It is the environment to develop 2D and 3D graphics. It gives the high visual quality and performance. It is cross platform environment.


OpenGl can process image data as well as geometric data.


LibGDX


It is the free game development framework, also it is open source. It is written in Java programming language with some components written in C and C++ to increase the performance. It is the cross platform framework. It can be used desktop application and also for android also.

However this framework is written in java, so the compiled bytecode is language dependent and can be used in any JVM. It main focus was to ease the simplicity and increase the performance.

Game Engine 


It is the tool for fast development of the 2D and 3D games. It is the software framework to develop the mobile and desktop games. The core functionality of the game engine are:-
  • rendering(for 2D and 3D graphics)
  • Physics(collision detection)
  • Sounds
  • Artificial Intelligence
  • Networking
  • Memory management and many more.....
It makes the portability and reusability of the code. There are so many game engines in the market right now, one can choose as per its convenience. Some popular Game Engines are:-
  • UNITY
  • UNREAL
  • RENDERWARE
  • X-RAY

WHAT TO CHOOSE!!


The choice is based on some factors like how much time is available, availability of resources, quality of product and many more. after considering all these points one should choose accordingly.

But my personal advice would be Game Engine as you can do so much in less time and no heavy programming skill is needed. Not because of less programming but the quality of content is far more good and manageability is easy. If one wants to develop the game from basic logic, one can to understand how things happen but if they want to build heavy game with simple libraries it will be surely very difficult. So, it is better to choose game engine.

I personally prefer the UNITY game engine as it is easy to learn and implement. Others are also good but I hadn't used them. Tutorials for all these are available online.


GAME ENGINE would be good option.  


Thursday, 22 June 2017

Log4j

Log4j is a Reliable, Fast and Flexible Logging Framework (APIs) written in Java which is distributed under the Apache Software License. Log4j is highly configurable through external configuration files at runtime. It views the logging process in terms of levels of priorities and offers mechanisms to direct logging information to a great variety of destinations, such as a database, file, console, UNIX Syslog etc.
Log4j has three main components:
  • loggers: Responsible for capturing logging information.
  • appenders : Responsible for publishing logging information to various preferred destinations.
  • layouts: Responsible to format logging information in different styles.
log4j Features:
  • log4j is thread-safe.
  • log4j supports multiple output appenders per logger.
  • log4j supports internationalization.
  • Logging behavior can be set at runtime using a configuration file.
  • log4j is designed to handle Java Exceptions from the start.
  • log4j uses multiple levels, namely ALL, TRACE, DEBUG, INFO, WARN, ERROR and FATAL.
  • The format of the log output can be easily changed by extending the Layout class.
Logging Methods:
Once we obtain an instance of a named logger, we can use several methods of the logger to log messages. The Logger class has the following methods for printing the logging information.
public void debug(Object message)
This method prints messages with the level Level.DEBUG.
public void error(Object message)
This method prints messages with the level Level.ERROR.
public void fatal(Object message);
This method prints messages with the level Level.FATAL.
public void info(Object message);
This method prints messages with the level Level.INFO.
public void warn(Object message);
This method prints messages with the level Level.WARN.
public void trace(Object message);
This method prints messages with the level Level.TRACE.
All the levels are defined in the org.apache.log4j.Level class and any of the above mentioned method can be called as follows:
import org.apache.log4j.Logger;  
 public class LogClass {  
  private static Logger log = Logger.getLogger(LogClass.class);  
  public static void main(String[] args) {  
   log.trace("Trace Message!");  
   log.debug("Debug Message!");  
   log.info("Info Message!");  
   log.warn("Warn Message!");  
   log.error("Error Message!");  
   log.fatal("Fatal Message!");  
  }  
 }  
When you compile and run LogClass program it would generate following result:

 Debug Message!   
 Info Message!   
 Warn Message!   
 Error Message!   
 Fatal Message!  
log4j - Log Formatting:
Apache log4j provides various Layout objects, each of which can format logging data according to various layouts. It is also possible to create a Layout object that formats logging data in an application-specific way
The Layout Types:
The top-level class in the hierarchy is the abstract class org.apache.log4j.Layout. This is the base class for all other Layout classes in the log4j API.
The Layout class is defined as abstract within an application, we never use this class directly; instead, we work with its subclasses which are as follows:
  • DateLayout
  • HTMLLayout
  • PatternLayout.
  • SimpleLayout
  • XMLLayout
log4j - Sample Program:
Following is a simple configuration file created for our example.It has the following information:
  • The level of the root logger is defined as DEBUG and attaches appender named FILE to it.
  • The appender FILE is defined as org.apache.log4j.FileAppender and writes to a file named "log.out" located in the log directory.
  • The layout pattern defined is %m%n, which means the printed logging message will be followed by a newline character.
So the content of log4j.properties file would be as follows:
# Define the root logger with appender file  
 log = /usr/home/log4j  
 log4j.rootLogger = DEBUG, FILE  
 # Define the file appender  
 log4j.appender.FILE=org.apache.log4j.FileAppender  
 log4j.appender.FILE.File=${log}/log.out  
 # Define the layout for file appender  
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout  
 log4j.appender.FILE.layout.conversionPattern=%m%n  
Using log4j in Java Program:
The following Java class is a very simple example that initializes, and then uses, the Log4J logging library for Java applications.
import org.apache.log4j.Logger;  
 import java.io.*;  
 import java.sql.SQLException;  
 import java.util.*;  
 public class log4jExample{  
  /* Get actual class name  to be printed on */  
  static Logger log =  Logger.getLogger(log4jExample.class.getName());  
  public static void main(String[] args) throws IOException,SQLException{  
   log.debug("Hello this is an debug message");  
   log.info("Hello this is an info message");  
  }  
 }  

Enjoy Reading :)

Friday, 16 June 2017

How to get Resolution of android device during runtime

How to get Resolution of android device during runtime


Getting Resolution of the android screen is one of the important aspect when application is to be made for different resolution devices.
So, in order to get the resolution of the device there is predefined library(Display Metrics) in android sdk. You just need to call the method provided by it. The methods are mentioned below.

 DisplayMetrics DM = new DisplayMetrics();  
 getWindowManager().getDefaultDisplay().getMetrics(DM);  

This DM object have the information about no. of pixels in height and width and density of the screen. To get these information Call following method:-

For no. of pixels in length

 DM.heightPixels;  

For no. of pixels in width

 DM.widthPixels;  

For Density of Screen

 DM.densityDpi;  

This information is used frequently in code so it is better to make a wrapper class of this and add some basic functions in it. The custom Wrapper class is defined below.

Wrapper Class for DM object


Firstly you have to pass the DM object to this class's constructor.

 DisplayMetrics DM = new DisplayMetrics();  
 getWindowManager().getDefaultDisplay().getMetrics(DM);  
 ScreenResolution SR = new ScreenResolution(DM);  

Now create the custom class named as ScreenResolution:-

import android.util.DisplayMetrics;
public class ScreenResolution { public static DisplayMetrics dm; public ScreenResolution(DisplayMetrics dm){ this.dm=dm; } public static int getHeight(){ return dm.heightPixels; } public static int getWidth(){ return dm.widthPixels; } public static int getDensity(){ return dm.densityDpi; } public static int percent_of_width(int param){ return ((param*(dm.widthPixels))/100); } public static int percent_of_height(int param){ return ((param*(dm.heightPixels))/100); } }

This class should be placed in custom Package. This class is beneficial in storing and getting the information about the screen's resolution.

ENJOY  DEVELOPING!!

Wednesday, 14 June 2017

ConcurrentHashMap in Java

ConcurrentHashMap

ConcurrentHashMap in Java is introduced as an alternative of Hashtable in Java 1.5 as part of Java concurrency package.  Prior to Java 1.5 if you need a Map implementation, which can be safely used in a concurrent and multi-threaded Java program, then you only have Hashtable or synchronized Map because HashMap is not thread-safe.
With ConcurrentHashMap, not only it can be safely used in concurrent multi-threaded environment but also provides better performance over Hashtable and synchronizedMap. ConcurrentHashMap performs better than earlier two because it only locks a portion of Map, instead of whole Map, which is the case with Hashtable and synchronized Map. ConcurrentHashMap allows concurred read operations and same time, maintains integrity by synchronizing write operations.

How ConcurrentHashMap is implemented in Java

ConcurrentHashMap provided all functions supported by Hashtable with additional feature called "concurrency level", which allows ConcurrentHashMap to partition Map. ConcurrentHashMap allows multiple readers to read concurrently without any blocking. This is achieved by partitioning Map into different parts based on concurrency level and locking only a portion of Map during updates. Default concurrency level is 16. This means, 16 thread can operate on Map simultaneously, until they are operating on different part of Map. This makes ConcurrentHashMap high performance despite keeping thread-safety intact. Though, it comes with warning. Since update operations like put(), remove(), putAll() or clear() is not synchronized, concurrent retrieval may not reflect most recent change on Map.
Another important point to remember is iteration over CHM, Iterator returned by keySet of ConcurrentHashMap are weekly consistent and they only reflect state of ConcurrentHashMap and certain point and may not reflect any recent change. Iterator of ConcurrentHashMap's keySet area also fail-safe and doesn’t throw ConcurrentModificationExceptoin.

ConcurrentHashMap putifAbsent example in Java

Many times we need to insert entry into Map, if it’s not present already, and we wrote following kind of code:

synchronized(map){  
  if (map.get(key) == null){  
    return map.put(key, value);  
  } else{  
    return map.get(key);  
  }  
 }  

Though this code will work fine in HashMap and Hashtable, This won't work in ConcurrentHashMap; because, during put operation whole map is not locked, and while one thread is putting value, other thread's get() call can still return null which result in one thread overriding value inserted by other thread. Of course, you can wrap whole code in synchronized block and make it thread-safe but that will only make your code single threaded. ConcurrentHashMap provides putIfAbsent(key, value) which does same thing but atomically and thus eliminates above race condition.
Eg:
public class ConcurrentHashMapTest implements Runnable {  
     private String name;  
     private static Map<String,String> conpage=new ConcurrentHashMap<String,String>();  
     ConcurrentHashMapTest(String name){  
        conpage.put("1","A");  
        conpage.put("2","B");  
        conpage.put("3","C");  
        this.name=name;  
     }  
     public void run() {  
        try{  
            Iterator<String> it = conpage.keySet().iterator();  
            while(it.hasNext()){  
               String key=it.next();  
               conpage.put("A"+key, "A"+key);  
            }  
            System.out.println(name +" completed.");  
        }catch(Exception e){  
            e.printStackTrace();  
        }  
     }  
     public static void main(String[] args) {  
        ExecutorService executor= Executors.newCachedThreadPool();  
        executor.execute(new ConcurrentHashMapTest("Thread one"));  
        Iterator<String> itt = conpage.keySet().iterator();  
        while(itt.hasNext()){  
            String key=itt.next();  
            System.out.println(conpage.get(key));  
        }  
        executor.execute(new ConcurrentHashMapTest("Thread two"));  
        Iterator<String> it = conpage.keySet().iterator();  
        while(it.hasNext()){  
            String key=it.next();  
            System.out.println(conpage.get(key));  
        }  
        executor.shutdownNow();  
     }     
 }  

Output-  
 A  
 C  
 B  
 Thread one completed.  
 A  
 A2  
 A1  
 A3  
 C  
 B  
 Thread two completed.  

When to use ConcurrentHashMap in Java

  • ConcurrentHashMap is best suited when you have multiple readers and few writers. If writers outnumber reader, or writer is equal to reader, than performance of ConcurrentHashMap effectively reduces to synchronized map or Hashtable.
  • ConcurrentHashMap is a good choice for caches, which can be initialized during application start up and later accessed my many request processing threads.
  • For those who have seen the green-box load jobs written in SpringBatch, many of the one-time populated Maps in beforeJob, whch are always read alone, are all ConcurrentHashMap ‘s.

Enjoy Learning :)

Eclipse and its Features

We work on Eclipse every day, but still we are not aware of all the powerful features of Eclipse. It provides a lot of shortcuts and other features which can help us in coding, debugging and other tasks, eventually delivering the bug free code in a lot lesser time.
Some of them are mentioned below and yet there are a lot more J 
Content Assist, Quick Fix and Class Navigation
Content assist
The content assistant allows you to get input help in an editor. It can be invoked by pressing CTRLSpace For example type syso in the editor of a Java source file and then press CTRLSpace. This will replace syso with System.out.println(""). If you have a reference to an object, for example the object person of the type Person and need to see it's methods, type person. and press CTRL+Space.
Quick Fix
Whenever Eclipse detects a problem, it will underline the problematic text in the editor. Select the underlined text and press CTRL1 to see proposals how to solve this problem. For example type myBoolean = true; If myBoolean is not yet defined, Eclipse will highlight it as an error. Select the variable and press CTRL1, Eclipse will suggest creating a field or local variable.
Quick Fix is extremely powerful. It allows you to create new local variables and fields as well as new methods and new classes. I can put try-catch statements around your exceptions. It can assign a statement to a variable and much more.
Opening a class
You can navigate between the classes in your project via the "Package Explorer" View. In addition you can open any class via positioning the cursor on the class in an editor and pressing F3. Alternatively, you can press CTRLShiftT. This will show a dialog in which you can enter the class name to open it.
Eclipse Shortcuts
Eclipse provides a lot of shortcuts to work efficiently with the IDE.
Table 1.  Navigation

Shortcut
Description
Ctrl + 2 + L
Assign statement to new local variable
Ctrl + 2 + F
Assign statement to new field
Table 4. Coding

Shortcut
Description
ALT + SHIFT + R
Rename
CTRL+2, R
Rename locally (in file), faster then ALT + SHIFT + R
ALT + SHIFT + T
Opens the quick refactoring menu
Table 6.  Handling the editor

Command
Description
F5
Goes to the next step in your program. If the next step is a method / function this command will jump into the associated code.
F6
F6 will step over the call, i.e. it will call a method / function without entering the associated code.
F7
F7 will go to the caller of the method/ function. This will leave the current code and go to the calling code.
F8
Use F8 to go to the next breakpoint. If no further breakpoint is encountered the program will run normally.

More Debugging Tips!!
  • If you want to temporary de-activate all your breakpoints you can press the button "Skip all breakpoints". This button is visible, if you select the "Breakpoints" tab. If you press this button again, your breakpoints will be reactivated.
    • After setting a breakpoint you can select the properties of the breakpoint, via right-click > Breakpoint Properties. You can define a condition that restricts when the breakpoint will become active.
    • watchpoint is a breakpoint set on a field. The debugger will stop whenever that field is read or changed.
    • You can set a watchpoint by double-clicking on the left margin, next to the field declaration. In the properties of a watchpoint you can define if the execution should stop during read access (Field Access) and during write access (Field Modification).
    • You can also set breakpoints which are triggered when exceptioins are thrown. To define an exception breakpoint click on the "Add Java Exception Breakpoint" icon in the "Breakpoints" View toolbar.
    • A method breakpoint is defined by double-clicking in the left margin of the editor next to the method header. You can define if you want to stop the program before entering or after leaving the method.
    • A Class Load Breakpoint will stop when the class is loaded. To set a class load breakpoint, right-click on a class in the Outline View and choose "Toggle Class Load Breakpoint".
For every breakpoint you can define a hit count in it's properties. The application is stopped once the breakpoint is reached the number of times defined in the hit count.

Templates
If you have to frequently type the same code / part of the document, you can create templates which can be activated via autocomplete (Ctrl + Space).
For example, assume that you are frequently creating public void name(){} methods. You could define a template which creates the method body for you.
To create a template for this, select the menu Window > Preferences > Java > Editor > Templates.



Press New. Create the template shown in the following screenshot.


cursor indicates that the cursor should be placed at this position after applying the template.
In this example the name "npm" is your keyword. Now every time you type "npm" in the Java editor and press CTRL+Space the system will allow you to replace your keyword with your template. 
 Automatic placement of semicolon
Eclipse can make typing more efficient by placing semicolons at the correct position in your source code.
In the Preference setting select Java > Editor > Typing. In the section "Automatically insert at correct position”, enable the "Semicolons" checkbox. You can now type a semicolon in the middle of your code and Eclipse will position it at the end of the current statement.



Enjoy Learning :)

Wednesday, 24 May 2017

Overview of HTTP Request Methods

HTTP defines methods (sometimes referred to as verbs) to indicate the desired action to be performed on the identified resource. What this resource represents, whether pre-existing data or data that is generated dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the output of an executable residing on the server.

The HTTP/1.0 specification section  defined the GET, POST and HEAD methods and the HTTP/1.1 specification section  added 5 new methods: OPTIONS, PUT, DELETE, TRACE and CONNECT. By being specified in these documents their semantics are well known and can be depended upon. Any client can use any method and the server can be configured to support any combination of methods. If a method is unknown to an intermediate it will be treated as an unsafe and non-idempotent method

GET
Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect.
HEAD
Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.
POST
Requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI. The data POSTed might be, as examples, an annotation for existing resources; a message for a bulletin board, newsgroup, mailing list, or comment thread; a block of data that is the result of submitting a web form to a data-handling process; or an item to add to a database
PUT
Requests that the enclosed entity be stored under the supplied URI. If the URI refers to an already existing resource, it is modified; if the URI does not point to an existing resource, then the server can create the resource with that URI.
DELETE
Deletes the specified resource.
TRACE
Echoes back the received request so that a client can see what (if any) changes or additions have been made by intermediate servers.
OPTIONS
Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource.
CONNECT
Converts the request connection to a transparent TCP/IP tunnel, usually to facilitate SSL-encrypted communication (HTTPS) through an unencrypted HTTP proxy.[14][15]
PATCH
Is used to apply partial modifications to a resource.
HTTP servers are required to implement at least the GET and HEAD methods and, whenever possible, also the OPTIONS method.

Safe methods
Implementers should be aware that the software represents the user in their interactions over the Internet, and should be careful to allow the user to be aware of any actions they might take which may have an unexpected significance to themselves or others.
In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.
Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.

Idempotent methods
Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent.
However, it is possible that a sequence of several requests is non- idempotent, even if all of the methods executed in that sequence are idempotent. (A sequence is idempotent if a single execution of the entire sequence always yields a result that is not changed by a reexecution of all, or part, of that sequence.) For example, a sequence is non-idempotent if its result depends on a value that is later modified in the same sequence.
A sequence that never has side effects is idempotent, by definition (provided that no concurrent operations are being executed on the same set of resources).

Persistent connections
In HTTP/0.9 and 1.0, the connection is closed after a single request/response pair. In HTTP/1.1 a keep-alive-mechanism was introduced, where a connection could be reused for more than one request. Such persistent connections reduce request latency perceptibly, because the client does not need to re-negotiate the TCP connection after the first request has been sent. Another positive side effect is that in general the connection becomes faster with time due to TCP's slow-start-mechanism.
Version 1.1 of the protocol also made bandwidth optimization improvements to HTTP/1.0. For example, HTTP/1.1 introduced chunked transfer encoding to allow content on persistent connections to be streamed rather than buffered. HTTP pipelining further reduces lag time, allowing clients to send multiple requests before waiting for each response. Another improvement to the protocol was byte serving, where a server transmits just the portion of a resource explicitly requested by a client.

Enjoy Learning.

HTTP Status Codes & Messages

This is a list of HTTP status messages that might be returned when a browser requests a service from a web server.
1xx:Information
Message:
Description:
100 Continue
The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols
The requester has asked the server to switch protocols
103 Checkpoint
Used in the resumable requests proposal to resume aborted PUT or POST requests
  
2xx:Successful
Message:
Description:
200 OK
The request is OK (this is the standard response for successful HTTP requests)
201 Created
The request has been fulfilled, and a new resource is created 
202 Accepted
The request has been accepted for processing, but the processing has not been completed
203 Non-Authoritative Information
The request has been successfully processed, but is returning information that may be from another source
204 No Content
The request has been successfully processed, but is not returning any content
205 Reset Content
The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view
206 Partial Content
The server is delivering only part of the resource due to a range header sent by the client
  
3xx:Redirection
Message:
Description:
300 Multiple Choices
A link list. The user can select a link and go to that location. Maximum five addresses  
301 Moved Permanently
The requested page has moved to a new URL 
302 Found
The requested page has moved temporarily to a new URL 
303 See Other
The requested page can be found under a different URL
304 Not Modified
Indicates the requested page has not been modified since last requested
306 Switch Proxy
No longer used
307 Temporary Redirect
The requested page has moved temporarily to a new URL
308 Resume Incomplete
Used in the resumable requests proposal to resume aborted PUT or POST requests
  
4xx:Client Error
Message:
Description:
400 Bad Request
The request cannot be fulfilled due to bad syntax
401 Unauthorized
The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided
402 Payment Required
Reserved for future use
403 Forbidden
The request was a legal request, but the server is refusing to respond to it
404 Not Found
The requested page could not be found but may be available again in the future
405 Method Not Allowed
A request was made of a page using a request method not supported by that page
406 Not Acceptable
The server can only generate a response that is not accepted by the client
407 Proxy Authentication Required
The client must first authenticate itself with the proxy
408 Request Timeout
The server timed out waiting for the request
409 Conflict
The request could not be completed because of a conflict in the request
410 Gone
The requested page is no longer available
411 Length Required
The "Content-Length" is not defined. The server will not accept the request without it 
412 Precondition Failed
The precondition given in the request evaluated to false by the server
413 Request Entity Too Large
The server will not accept the request, because the request entity is too large
414 Request-URI Too Long
The server will not accept the request, because the URL is too long. Occurs when you convert a POST request to a GET request with a long query information 
415 Unsupported Media Type
The server will not accept the request, because the media type is not supported 
416 Requested Range Not Satisfiable
The client has asked for a portion of the file, but the server cannot supply that portion
417 Expectation Failed
The server cannot meet the requirements of the Expect request-header field
  
5xx:Server Error
Message:
Description:
500 Internal Server Error
A generic error message, given when no more specific message is suitable
501 Not Implemented
The server either does not recognize the request method, or it lacks the ability to fulfill the request
502 Bad Gateway
The server was acting as a gateway or proxy and received an invalid response from the upstream server
503 Service Unavailable
The server is currently unavailable (overloaded or down)
504 Gateway Timeout
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server
505 HTTP Version Not Supported
The server does not support the HTTP protocol version used in the request
511 Network Authentication Required
The client needs to authenticate to gain network access
Enjoy Learning.