Monday 29 December 2014

Eclipse Shortcut Keys

Ctrl + 3

Usually coders have trouble finding files in a long list of projects, and it can be time-consuming to find a file. This shortcut brings up the quick access box, that brings up files, views and commands as you are searching for them. Instead of drilling down in the explorer, just search for it!

Ctrl + Shift + G

Finds references to a variable throughout the workspace.

Ctrl + F8

Shift between perspectives (Java, Debug, DDMS) quickly

Ctrl + F11

Run last launched application.

Ctrl + Space

If you forget a function,variable or class name, just type a couple of letters and hit this shortcut to autocomplete with suggestions. Even generates conditional statements after matching with starting words.

Ctrl + O

Displays all the methods and variables and methods available in the current class selected.

Ctrl + Shift + O

Organize imports. This comes very handy when you suddenly have to pull up external classes and functions (such as the Math class) and Java will throw a syntax error. With this shortcut, the missing packages will automatically be imported.

Ctrl + Shift + F

This shortcut automatically formats your code, according to predefined formatting rules set in the IDE. This is a boon for all the messy programmers out there who need their code to be indented properly!

Ctrl + Shift + P

Finds the matching bracket for the current body of code. Very useful when figuring out missing bracket syntax issues.

Ctrl + PgUp/PgDn

Toggles between editor views, much faster to switch between different classes user is working on.

Alt + Shift + Z

Surround a block of code with a try/catch clause.

Alt + Shift + R

Rename any variable,method or class and Eclipse automatically renames all references.

Alt + Shift + L

Highlight an expression commonly used in your program and extract it as a variable- this will make your code cleaner.

Ctrl + 1

Quickfix. Wherever Eclipse shows an error, this shortcut can be used to quickly solve the problem with one of the suggestions shown.

Alt + Shift + T

Opens the quick refactoring menu. Can choose from a variety of refactorings to make the code cleaner and more efficient.

Ctrl + Shift + T

Open/Search for types

Ctrl + Q

Position the cursor back at the last changed location in the editor.

Alt + Shift + N

Open up create menu directly to choose a new class/project.

F4 while selecting variable

Show type hierarchy.

Ctrl + 2,L or F

Assign statement/expression to a new local variable or field.

Saturday 27 December 2014

Java Arrays

Description     
     An array is a group of similar typed variables that are referred to by a common name. Arrays of any type can be created and may have one or more dimensions. A specific element in an array is accessed by its index. Array is simple type of data structure which can store primitive variable or objects. For example, imagine if you had to store the result of six subjects we can do it using array. To create an array value in Java, you use the new keyword, just as you do to create an object.

Defining and constructing one dimensional array

      Here, type specifies the type of variables (int, boolean, char, float etc) being stored, size specifies the number of elements in the array, and array-name is the variable name that is reference to the array. Array size must be specified while creating an array. If you are creating a int[], for example, you must specify how many int values you want it to hold (in above statement resultArray[] is having size 6 int values). Once an array is created, it can never grow or shrink.

Initializing array: You can initialize specific element in the array by specifying its index within square brackets. All array indexes start at zero.

                              resultArray[0]=69;

This will initialize first element (index zero) of resultArray[] with integer value 69. Array elements can be initialized/accessed in any order. In memory it will create structure similar to below figure.


Array Literals

      The null literal used to represent the absence of an object can also be used to represent the absence of an array. For example:

                    String [] name = null;

In addition to the null literal, Java also defines special syntax that allows you to specify array values literally in your programs. This syntax can be used only when declaring a variable of array type. It combines the creation of the array object with the initialization of the array elements:

                      String[] daysOfWeek = {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”,                                                                “Friday”, “Saturday”};
This creates an array that contains the seven string element representing days of the week within the curly braces. Note that we don't use the new keyword or specify the type of the array in this array literal syntax. The type is implicit in the variable declaration of which the initializer is a part. Also, the array length is not specified explicitly with this syntax; it is determined implicitly by counting the number of elements listed between the curly braces.

Let’s see sample java program to understand this concept better. This program will help to understand initializing and accessing specific array elements.

package arrayDemo;

import java.util.Arrays;

public class ResultListDemo {


public static void main(String[] args) {
//Array Declaration
int resultArray[] = new int[6];
//Array Initialization
resultArray[0]=69;
resultArray[1]=75;
resultArray[2]=43;
resultArray[3]=55;
resultArray[4]=35;
resultArray[5]=87;
//Array elements access
System.out.println("Marks of First Subject- "+ resultArray[0]);
System.out.println("Marks of Second Subject- "+ resultArray[1]);
System.out.println("Marks of Third Subject- "+ resultArray[2]);
System.out.println("Marks of Fourth Subject- "+ resultArray[3]);
System.out.println("Marks of Fifth Subject- "+ resultArray[4]);
System.out.println("Marks of Sixth Subject- "+ resultArray[5]);
}

}

Output



Alternative syntax for declaring, initializing of array in same statement

                  int [] resultArray = {69,75,43,55,35,87};

Multidimensional Arrays

In Java, multidimensional arrays are actually arrays of arrays. These, as you might expect, look and act like regular multidimensional arrays. However, as you will see, there are a couple of subtle differences. To declare a multidimensional array variable, specify each additional index using another set of square brackets. For example, the following declares a two dimensional array variable called twoDim. This will create matrix of the size 2x3 in memory.

                   int twoDim[][] = new int[2][3];




Let’s have look at below program to understand 2-dimentional array

package arrayDemo;

public class twoDimArrayDemo {

public static void main (String []args){

int twoDim [][] = new int [2][3];
twoDim[0][0]=1;
twoDim[0][1]=2;
twoDim[0][2]=3;
twoDim[1][0]=4;
twoDim[1][1]=5;
twoDim[1][2]=6;

System.out.println(twoDim[0][0] + " " + twoDim[0][1] + " " + twoDim[0][2]);
System.out.println(twoDim[1][0] + " " + twoDim[1][1] + " " + twoDim[1][2]);
}

}

Output

Inbuilt Helper Class (java.util.Arrays) for Arrays Manipulation:

Java provides very important helper class (java.util.Arrays) for array manipulation. This class has many utility methods like array sorting, printing values of all array elements, searching of element, copy one array into other array etc. Let’s see sample program to understand this class for better programming. In below program float array has been declared. We are printing the array elements before sorting and after sorting.

package arrayDemo;

import java.util.Arrays;

public class ArraySortingDemo {

public static void main(String[] args) {
//Declaring array of float elements
float [] resultArray = {69.4f,75.3f,43.22f,55.21f,35.87f,87.02f};
System.out.println("Array Before Sorting- " + Arrays.toString(resultArray));
//below line will sort the array in ascending order
Arrays.sort(resultArray);
System.out.println("Array After Sorting- " + Arrays.toString(resultArray));
}
}

Output



Similar to “java.util.Arrays” System class also has functionality of efficiently copying data from one array to another. Syntax as below,

    public static void arraycopy(Object src, int srcPos,Object dest, int destPos, int length)

The two Object arguments specify the array to copy from and the array to copy to. The three int arguments specify the starting position in the source array, the starting position in the destination array, and the number of array elements to copy.

Important points:

You will get “ArrayIndexOutOfBoundsException” if you try access an array with an illegal index, that is with a negative number or with a number greater than or equal to its size.
Arrays are widely used with loops (for loops, while loops). There will be more sample program of arrays with loops tutorial.

Summary

An array is a group of similar typed variables that are referred to by a common name.
Array can be declared using indexes or literals.
Single dimensional array is widely used but we can have multi-dimensional.

Wednesday 17 December 2014

What is Cloud Computing ?

Cloud Computing! is a concept of abstract computing with resources delivery on demand.

     I am trying to explain like a drop in the ocean about Cloud Computing.
What it is ?
why it is? and
am I in Cloud Computing?.
My answer is – Yes
      if you are working with internet technology, You are related with cloud computing. While you are working on your personal computer with the internet connection, You are connected with the cloud networks.

      In a cloud computing the resources of hardware and networking are shared over the internet. A company providing the services of cloud computing (like: Amazon, IBM) provides the network infrastructure world wide, where users share resources with lower cost. In cloud computing we don’t need to setup own server rooms, hardware, etc individually. We just use them through web browser even we don’t know where the servers situated.

      For an example of Amazon cloud services. We just Login to our AWS management console through web browser and can create, manage server instances, s3 and many other services. It’s not to be bad to say a Single window management for all your network services.

Services of Cloud Computing ?

Cloud computing services are divided into three categories: Infrastructure as a Service (IaaS), Platform as a Service (PaaS), Software as a Service (Saas).


Deployment Models of Cloud Computing 

      Cloud Computing mainly has 4 deployment models with there own working process and accessibilities.

                        Public
                        Private
                        Hybrid

                        Community

Benefits cloud computing ?

1. Low cost - Mostly cloud services are available with cheaper costs due to its resource sharing. Like cloud services providers take a full advantages of virtualization.

2. Easy to Manage - Cloud services are easy to manage, we don’t need to work physically with the devices.

3. Flexibility & Scalability - As much as my experience with cloud computing, It’s is very flexible, We can create servers within minutes. We can use or start any services with the few clicks only. The most impotent feature is Scalability. If our organization grows, we can add more service of upgrade existing services within a minute.

4. Pay-Per-Use Services - Most of cloud services providers offers to Pay-Per-Use services. it means there are no boundation of billing date time. Like if we started any server for 1 hours only, we need to pay for 1 hour only.

Reference http://tecadmin.net/

How to Install JAVA 7 (JDK 7u71) on RedHat 6/5

      During installation of Java using rpm and tar files I faced issues many times. After that I found a better way to install java from Sun site. We can also install multiple version of java easily if required.
Using below steps I have installed java successfully,

Step 1: Download Archive File
For 32 Bit –

              $ cd /usr/local/java

              $ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-i586.tar.gz"

For 64 Bit –

             $ cd /usr/local/java

             $ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.tar.gz"

After completing download, Extract archive using following command. Use archive file as per your system configuration.
           
              $ tar -xzf jdk-7u71-linux-x64.tar.gz

Step 2: Setup Environment Variables

      After extracting java archive file, we just need to export the JAVA_HOME and AVA_BIN.  Most of java based application’s uses environment variables to work.
Use following commands to set up it.
Open .bash_profile from user home directory using following command copy the export JAVA_HOME path and save the .bash_profile and restart the putty session.

              $ vi .bash_profile
               export JAVA_HOME=/usr/local/java/jdk1.7.0_71
               PATH=$JAVA_HOME:$JAVA_HOME/bin:$PATH:$HOME/bin
               export PATH
Step 3: Check JAVA Version

Use following command to check which version of java is currently being used by system.
             
              # java -version

                      java version "1.7.0_71"
                      Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
                      Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

We are done with java installation on RedHat 6,  now we can start working with installed java.

For more information and reference check http://tecadmin.net/

Wednesday 8 October 2014

Ajax_Struts2_Jquery

Tutorials:Getting Started with jQuery

Setup

To start, we need a copy of the jQuery library, which we can get from the main download page. The jQuery Starterkit provides some markup and CSS to work with. After downloading and extracting its content we put jquery.js into the same directory and open starterkit.html and custom.js with our favorite editor and starterkit.html with a browser.
Now we have everything to start with the notorious "Hello world" example.

Hello jQuery

We start with an empty html page:
 <html>                                                                  
 <head>                                                                  
 <script type="text/javascript" src="jquery.js"></script>          
 <script type="text/javascript">                                         
   // we will add our javascript code here                                     
 </script>                                                               
 </head>                                                                 
 <body>                                                                  
   <!-- we will add our HTML content here -->                                        
 </body>                                                                 
 </html>
This page just loads the jquery.js library (make sure the URL points to where you stored your copy of jquery! This example assumes that you store it in the same directory as this example file). Two comments indicate where we will expand this template with code.
As almost everything we do when using jQuery reads or manipulates the document object model (DOM), we need to make sure that we start adding events etc. as soon as the DOM is ready.
To do this, we register a ready event for the document.
 $(document).ready(function() {
   // do stuff when DOM is ready
 });
Putting an alert into that function does not make much sense, as an alert does not require the DOM to be loaded. So lets try something a little more sophisticated: Show an alert when clicking a link.
Add the following to the <body>:
 <a href="">Link</a>
Now update the $(document).ready handler:
 $(document).ready(function() {
   $("a").click(function() {
     alert("Hello world!");
   });
 });
This should show the alert as soon as you click on the link.
Lets have a look at what we are doing: $("a") is a jQuery selector, in this case, it selects all a elements. $ itself is an alias for the jQuery "class", therefore $() constructs a new jQuery object. The click() function we call next is a method of the jQuery object. It binds a click event to all selected elements (in this case, a single anchor element) and executes the provided function when the event occurs.
This is similar to the following code:
 <a href="" onclick="alert('Hello world')">Link</a>
The difference is quite obvious: We don't need to write an onclick for every single element. We have a clean separation of structure (HTML) and behavior (JS), just as we separate structure and presentation by using CSS.
With this in mind, we explore selectors and events a little further.
Interesting links for this section:

Find me: Using selectors and events

jQuery provides two approaches to select elements. The first uses a combination of CSS and XPath selectors passed as a string to the jQuery constructor (eg. $("div > ul a")). The second uses several methods of the jQuery object. Both approaches can be combined.
To try some of these selectors, we select and modify the first ordered list in our starterkit.
To get started, we want to select the list itself. The list has an ID "orderedlist". In classic JavaScript, you could select it by using document.getElementById("orderedlist"). With jQuery, we do it like this:
 $(document).ready(function() {
   $("#orderedlist").addClass("red");
 });
The starterkit provides a stylesheet with a class "red" that simply adds a red background. Therefore, when you reload the page in your browser, you should see that the first ordered list has a red background. The second list is not modified.
Now lets add some more classes to the child elements of this list.
 $(document).ready(function() {
   $("#orderedlist > li").addClass("blue");
 });
This selects all child lis of the element with the id orderedlist and adds the class "blue".
Now for something a little more sophisticated: We want to add and remove the class when the user hovers the li element, but only on the last element in the list.
 $(document).ready(function() {
   $("#orderedlist li:last").hover(function() {
     $(this).addClass("green");
   },function(){
     $(this).removeClass("green");
   });
 });
There are many other selectors similar to CSS and XPath syntax. More examples and a list of all available expressions can be found here.
For every onxxx event available, like onclick, onchange, onsubmit, there is a jQuery equivalent. Some other events, like ready and hover, are provided as convenient methods for certain tasks.
You can find a complete list of all events in the jQuery Events Documentation.
With those selectors and events you can already do a lot of things, but there is more.
 $(document).ready(function() {
   $("#orderedlist").find("li").each(function(i) {
     $(this).append( " BAM! " + i );
   });
 });
find() allows you to further search the descendants of the already selected elements, therefore $("#orderedlist").find("li") is mostly the same as $("#orderedlist li").
each() iterates over every element and allows further processing. Most methods, like addClass(), use each() themselves.
In this example, append() is used to append some text to it and set it as text to the end of each element.
Another task you often face is to call methods on DOM elements that are not covered by jQuery. Think of a form you would like to reset after you submitted it successfully via AJAX.
 $(document).ready(function() {
   // use this to reset a single form
   $("#reset").click(function() {
     $("form")[0].reset();
   });
 });
This code selects the first form element and calls reset() on it. In case you had more than one form, you could also do this:
 $(document).ready(function() {
   // use this to reset several forms at once
   $("#reset").click(function() {
     $("form").each(function() {
       this.reset();
     });
   });
 });
This would select all forms within your document, iterate over them and call reset() for each. Note that in an .each() function, this refers to the actual element. Also note that, since the reset() function belongs to the form element and not to the jQuery object, we cannot simply call $("form").reset() to reset all the forms on the page.
An additional challenge is to select only certain elements from a group of similar or identical ones. jQuery provides filter() and not() for this. While filter() reduces the selection to the elements that fit the filter expression, not() does the contrary and removes all elements that fit the expression. Think of an unordered list where you want to select all li elements that have no ul children.
 $(document).ready(function() {
   $("li").not(":has(ul)").css("border", "1px solid black"); 
 });
This selects all li elements that have a ul element as a child and removes all elements from the selection. Therefore all li elements get a border, except the one that has a child ul.
The [expression] syntax is taken from XPath and can be used to filter by attributes. Maybe you want to select all anchors that have a name attribute:
 $(document).ready(function() {
   $("a[name]").css("background", "#eee" );
 });
This adds a background color to all anchor elements with a name attribute.
More often than selecting anchors by name, you might need to select anchors by their "href" attribute. This can be a problem as browsers behave quite inconsistently when returning what they think the "href" value is (Note: This problem was fixed recently in jQuery, available in any versions after 1.1.1). To match only a part of the value, we can use the contains select "*=" instead of an equals ("="):
 $(document).ready(function() {
   $("a[href*=/content/gallery]").click(function() {
     // do something with all links that point somewhere to /content/gallery
   });
 });
Until now, all selectors were used to select children or filter the current selection. There are situations where you need to select the previous or next elements, known as siblings. Think of a FAQ page, where all answers are hidden first, and shown, when the question is clicked. The jQuery code for this:
 $(document).ready(function() {
   $('#faq').find('dd').hide().end().find('dt').click(function() {
     $(this).next().slideToggle();
   });
 });
Here we use some chaining to reduce the code size and gain better performance, as '#faq' is only selected once. By using end(), the first find() is undone, so we can start search with the next find() at our #faq element, instead of the dd children.
Within the click handler, the function passed to the click() method, we use $(this).next() to find the next sibling starting from the current dt. This allows us to quickly select the answer following the clicked question.
In addition to siblings, you can also select parent elements (also known as ancestors for those more familiar with XPath). Maybe you want to highlight the paragraph that is the parent of the link the user hovers. Try this:
 $(document).ready(function(){
   $("a").hover(function(){
     $(this).parents("p").addClass("highlight");
   },function(){
     $(this).parents("p").removeClass("highlight");
   });
 });
For all hovered anchor elements, the parent paragraph is searched and a class "highlight" added and removed.
Lets go one step back before continuing: jQuery is a lot about making code shorter and therefore easier to read and maintain. The following is a shortcut for the $(document).ready(callback) notation:
 $(function() {
   // code to execute when the DOM is ready
 });


Applied to the Hello world! example, we end with this:
 $(function() {
   $("a").click(function() {
     alert("Hello world!");
   });
 });
Now, with the basics at hand, we want to explore some other aspects, starting with AJAX.
Interesting links for this chapter:

 



API/1.1.2/DOM/Traversing/Selectors

jQuery selectors are a combination of CSS 1-3, XPath, plus some custom code to glue it together. Essentially, the best parts from both of these query languages were taken, combined, and used to create the final jQuery expression language. If you already know CSS (which most web developers do) then you're going to be fine.
If you are unsure about the general differences between the techniques discussed here, these articles in the English Wikipedia may help clarify a lot: XPath and [

Using CSS and XPath Together

This is a point of confusion, for some: How can you use CSS and XPath together, they're so different! jQuery makes some allowances to make this happen, but we think that developers will really appreciate the advantages of each language. Here are some examples:
Hide all Paragraph elements that contain a class attribute:
 $("p[@class]").hide();

Show the first paragraph on the page:
 $("p:eq(0)").show();

Hide all divs that are currently showing:
 $("div:visible").hide();

Get all list items that are children of an unordered list:
 $("ul/li")
 /* valid too: $("ul > li") */

Get all Paragraphs, with a class of 'foo', that have a link in them:
 $("p.foo[a]");

Get list item that contains link with "Register" text inside:
 $("li[a:contains('Register')]");

Get the input field's value with the name of 'bar':
 $("input[@name=bar]").val();

All checked radio buttons:
 $("input[@type=radio][@checked]")
If you still have questions concerning how this selector language works, please feel free to post to the mailing list.

CSS Selectors

jQuery has full CSS 1-2 support and partial CSS 3 support, along with some custom CSS-like functionality (and XPath), as part of its expression.
For info on how CSS works feel free to read the various links:
What follows is a list of supported CSS Selector expressions.
  • * any element
  • E an element of type E
  • E:nth-child(n) an E element, the n-th child of its parent
  • E:first-child an E element, first child of its parent
  • E:last-child an E element, last child of its parent
  • E:only-child an E element, only child of its parent
  • E:empty an E element that has no children (including text nodes)
  • E:enabled a user interface element E which is not disabled
  • E:disabled a user interface element E which is disabled
  • E:checked a user interface element E which is checked (for instance a radio-button or checkbox)
  • E:selected a user interface element E which is selected (one or more option elements inside a select) - not in the CSS spec, but nonetheless supported by jQuery
  • E.warning an E element whose class is "warning"
  • E#myid an E element with ID equal to "myid". (Will only match, at most, one element.)
  • E:not(s) an E element that does not match simple selector s
  • E F an F element descendant of an E element
  • E > F an F element child of an E element
  • E + F an F element immediately preceded by an E element
  • E ~ F an F element preceded by an E element
  • E,F,G select all E elements, F elements, and G elements

Supported, but different

All attribute selectors are written like their XPath counter-parts (in that all attributes should begin with an @ symbol).
  • E[@foo] an E element with a "foo" attribute
  • E[@foo=bar] an E element whose "foo" attribute value is exactly equal to "bar"
  • E[@foo^=bar] an E element whose "foo" attribute value begins exactly with the string "bar"
  • E[@foo$=bar] an E element whose "foo" attribute value ends exactly with the string "bar"
  • E[@foo*=bar] an E element whose "foo" attribute value contains the substring "bar"
  • E[@foo=bar][@baz=bop] an E element whose "foo" attribute value is exactly equal to "bar" and whose "baz" attribute is exactly equal to "bop"

Not supported

jQuery only supports selectors that actually select DOM elements - everything else is ignored.
  • E:link
  • E:visited an E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited)
  • E:active
  • E:hover
  • E:focus an E element during certain user actions
  • E:target an E element being the target of the referring URI
  • E::first-line the first formatted line of an E element
  • E::first-letter the first formatted letter of an E element
  • E::selection the portion of an E element that is currently selected/highlighted by the user
  • E::before generated content before an E element
  • E::after generated content after an E element

jQuery doesn't support the following selectors due to their lack of real-world usefulness:
  • E:nth-last-child(n) an E element, the n-th child of its parent, counting from the last one
  • E:nth-of-type(n) an E element, the n-th sibling of its type
  • E:nth-last-of-type(n) an E element, the n-th sibling of its type, counting from the last one
  • E:first-of-type an E element, first sibling of its type
  • E:last-of-type an E element, last sibling of its type
  • E:only-of-type an E element, only sibling of its type
  • E:lang(fr) an element of type E in language "fr"
  • E[foo~="test"] an E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "test"
  • E[hreflang|="en"] an E element whose "hreflang" attribute has a hyphen-separated list of values beginning (from the left) with "en"

Context and Anchoring

In jQuery, unlike real CSS, a selector expression may have a context other than the entire document, for instance with the function $(expr, context). You can anchor a CSS-like expression to the context root by starting it with one of the selectors >, +, or ~.

XPath Selectors

One of the selector languages that jQuery supports, as a part of its expression language is XPath. jQuery supports basic XPath expressions, in addition to CSS 1-3. Here are some samples:

Location Paths

  • Relative to the entire HTML document
 $("/html/body//p")
 $("body//p")
 $("p/../div")
  • Relative to the context node this
 $("p/*", this)

 $("/p//a", this)

Web-Services Comparisons with SOAP and REST



Web Services Developing with SOAP and REST

There are currently two schools of thought in developing Web Services – one being the standards-based traditional approach [SOAP] and the other, simpler school of thought [REST].

What is SOAP?
Defined as Simple Object Access Protocol, it is a specification for exchanging structured information using Extensible Markup Language (XML) and usually HTTP protocol for transmission. SOAP also uses Web Services Description Language (WSDL) documents that provide a model for describing web services. Basically, it defines what the SOAP request (client-side) and response (server-side) should look like.

What is REST?
The acronym REST stands for Representational State Transfer, meaning each unique URL represents some object. The architecture was developed by Roy Fielding, one of the authors of the Hypertext Transfer Protocol (HTTP). A REST Web Service uses HTTP and supports the HTTP GET, POST, PUT or DELETE methods.

How popular is REST?
All of the major web services on the Internet now use REST: Twitter, Yahoo’s web services use REST, others include Flicker, del.icio.us, pub.sub, blog, lines, techno and several others. Both eBay and Amazon have web services for both REST and SOAP.







Basic differences:
REST
SOAP
Pros
Cons
Pros
Cons
Lightweight
Point-to-point communication
Easy to consume
More difficult to setup
Human Readable
Lack of standards
Standards (WSDL,XSD, policy etc)
More verbose
Easier to build
Tied to HTTP
Distributed computing
Harder to develop


Detail level comparisons for SOAP and REST:
REST
SOAP
Assumes a point-to-point communication model–not usable for distributed computing environment where message may go through one or more intermediaries
Designed to handle distributed computing environments
Minimal tooling/middleware is necessary. Only HTTP support is required
Requires significant tooling/middleware support
URL typically references the resource being accessed/deleted/updated
The content of the message typically decides the operation
Not reliable – HTTP DELETE can return OK status even if a resource is not deleted
Reliable
URL typically references the resource being accessed/deleted/updated
The content of the message typically decides the operation
Not reliable – HTTP DELETE can return OK status even if a resource is not deleted
Reliable
Formal description standards not in widespread use. WSDL 1.2, WADL are candidates.
Well defined mechanism for describing the interface e.g. WSDL+XSD, WS-Policy
Better suited for point-to-point or where the intermediary does not play a significant role
Well suited for intermediated services
No constraints on the payload
Payload must comply with the SOAP schema
Only the most well established standards apply e.g. HTTP, SSL. No established standards for other aspects.  DELETE and PUT methods often disabled by firewalls, leads to security complexity.
A large number of supporting standards for security, reliability, transactions.
Built-in error handling (faults)
No error handling
Tied to the HTTP transport model
Both SMTP and HTTP are valid application layer protocols used as Transport for SOAP
Less verbose
More verbose


Communications link failure

Communications-link-failure-due-to-underlying-exception, go through the following link

http://communications-link-failure.blogspot.in/