Saturday, March 4, 2017

What is Apache Camel

In this article we will learn and understand what is Apache Camel and how to use Camel and what is need of Apache Camel. We will discuss all these questions. Now,let me define what is Apache Camel?

Apache Camel is an Open Source integration framework that aims to make integrating system easier. We depend daily on multitude of such integrated systems,making possible everything from phone communications,financial transactions,and healthcare to travel planning and entertainment.

Camel's focus is on simplifying integration. A Camel framework is a routing engine. It allows you to define a routing rules,decides from which sources to accept messages,and determine how to process and send those messages to other destinations.

Camel lets you create the Enterprise Integration patterns to implement routing rules in either a Java based Domain Specific Language(DSL) or via Spring based XML Configuration files or Via Scala DSL. Apache Camel is small library which has minimal dependencies for easy embedding in any java application. Apache Camel has powerful Bean binding  and can easily integrated with popular framework such as Spring.

what is the need of Camel:

The Camel contains rich set of features. The following features are the main ideas behind camel.

Routing and mediation engine:

The core feature of Camel is Routing and mediation engine. A Routing engine will selectively move a message around and based on route's configuration.

Domain Specific Language(DSL):

Camel DSL is  a major contribution to the integration space. Camel is unique because it offers multiple DSLs in regular programming languages such as Java,Groovy,Scala. The main purpose of DSL is to allow the developer to focus on the integration problem rather than on the tool the programming language.

Pojo Model:

POJO's (Beans)are simply ordinary class in Camel. You can use these classes anywhere in your integration project.

Easy Configuration:

In order to configure endpoint directly in routes,Camel uses an easy and intuitive URI configuration. 

Modular and pluggable Architecture:

Camel has a modular architecture,which allows any component to be loaded into Camel,regardless of whether the component ship with Camel,is from a third party, or is your own custom creation.

Test Kit:

Camel provides a Test Kit that makes you to test your Camel application in easy way.

Lightweight:

Camel is very Lightweight with total library coming in at about 1.6MB. This makes camel easy embed and deploy anywhere you like,such as standalone application,Spring application,JEE application,web application,Google App engine etc..







Wednesday, March 1, 2017

HTTP Status Codes and their Purpose

In this article i am going to describe each of the status codes available for use in servlets talking to HTTP clients,along with the standard message associated with each code. Http(Hyper Text Transfer Protocol) is that web browsers and servers use to transfer hyper text pages and images. Here is how it works. When a client requests a file from an HTTP server an action known as a hit,it simply sends name of the file in a special format and server responds back to the content of the file. The server also responds with a status code to tell the client whether or not the request can be fulfilled.

The following are the specific status codes and their purpose:






HTTP status codes indicate whether a specific  HTTP request has been successfully completed. These responses are categorized in five classes they are informational responses,successful responses,client errors,server errors,redirects. Now we will discuss one by one.

Information responses:

100 continue:

This response indicates that everything so far is OK and that the client should continue with the request or ignore if it is already finished. 

103 Processing:

This code indicates that the server has received and is processing the request,but no response is available yet. 

Successful Response:

200 OK:

This response indicates the request has succeeded. That means successfully completed their respective method through sending HTTP Request. The methods might be GET(),POST(),Head().

201 Created:

The request has succeeded and new resource has been created as a result of it.



 Redirection Messages:

300 Multiple Choice:

The request has more than one possible responses. User should choose one of them. There is no standard way to choose one of the responses.

301 Moved Permanently:

This response code means that URI of requested resource has been changed.

305 (use Proxy):

 This means requested response must be accessed by a proxy. This response code is not largely supported because security reasons.

Client Error Response:

400 (Bad Request):

This response indicates that server could not understand the request due to invalid syntax.

401 (Unauthorized):

Authentication is needed to get requested response. That means client does not have access rights to the content so server is rejecting to give proper response.

404 (Not Found):

This response indicates that server can not find requested resource. This is most famous one due to its frequency to occur in web.

Server Error Response:

500 (Internal Server Error):

This indicates that the Server has encountered a situation it doesn't know how to handle.

505 (HTTP version not supported):

This response indicate that the HTTP version used in the request is not supported by the server.

  Watch video:  Best HTTP Status codes and their meaning
 See Also:

Difference Between doGet() and doPost() methods
Spring Interview questions
JSP Interview Questions
MVC Architecture in Java

 

 

     

  

 

What is doGet() and doPost() methods in Servlet

The Servlet interface is the central abstraction of the Servlet API. All servlets implement this either directly or commonly by extending a class that implements the interface. The TWO classes in the Servlet API that implement Servlet interface are GenericServlet and HttpServlet. For most purposes developers will extend HttpServlet to implement their Servlets.

HttpServelt class extends the GenericServlet. It is commonly used when developing Servlets that receive and process requests. The HttpServlet class provides specilized methods that handle the various types of HTTP requests.These method are doGet(),doOptions(),doDelete(),doHead(),doPost(),doPut(),doTrace(). A Servlet developer typically overrides one of these methods. In this post we will discuss only doGet() and doPost() methods because these are commonly used when handling form input.



Handling HTTP Get Requests:

Here we will discuss a Servlet that handles an HTTP GET Request. The GET method is the most common form of HTTP Request.The Servlet is invoked when a form on a webpage is submitted. When a Servlet Container first routes to a Servlet, it invokes the service() method.By default, the service() method will dispatch to the doGet() or doPost() based on the method information given in the HTTP Request Header.You must override doGet() method. The doGet() method receives HttpServelt Request and HttpServeltResponse object and must throw java.io.ServeltException and java.io.IOException.

Example:
public void doGet(HttpServletRequest req,HttpServeltResponse res)throws 
ServeltException,IOException
{
res.setContentType("text/html");

PrintWriter out=res.getWriter();
out.println("learnprogrammingbyluckysir");
}

Note: 

1)The doGet() method is overridden to process any HTTP GET request that are sent to the Servlet. It uses getParameter() method of HttpServeletRequest. 

2) Parameters for an HTTP GET request are included as part of the URL that is sent to the web browser.



Handling HTTP POST Requests:

Here we will learn a Servlet that handles an HTTP Post requests. HTTP employs the POST method to transfer larger amounts of HTML Form data.The doPost() method called much like doGet() method. If the Servlet's service() method receives an HTTP POST request,the Servlets's doPost() method is called.

The doPost() method is overridden to process any HTTP POST request that are sent to the Servlet. It uses getParameter() method of HttpServeletRequest. The doPost() method receives HttpServelt Request and HttpServeltResponse object and must throw java.io.ServeltException and java.io.IOException.

Example:

public void doPost(HttpServletRequest req,HttpServeltResponse res)throws 
ServeltException,IOException
{
res.setContentType("text/html");

PrintWriter out=res.getWriter();
out.println("learnprogrammingbyluckysir");
}

Note: Parameters for HTTP POST Request are not included as part of the URL that is sent to the web browser. The parameters names and values are sent in the body of the HTTP request.

Difference Between doGet() and doPost():

Recommend To Read:

JSP Interview Questions
Servlet Interview Questions
Spring Interview Questions
Struts Interview Questions
Hibernate Interview Questions
Servlet Life cycle

Let me know your comments  write down in the below post and share this post and keep follow me for latest updates.

High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...