Friday, August 17, 2012

Java EE Architecture

First of all, we will say J2EE is not a product. Rather it is specification that defines the standard for the development of multitier enterprise applications in Java.


Formation of Architecture

Whenever we think about client-server concept then immediately first thing come in picture that there is a client asks for a resource to server. Here at least two things can happen.
1. Server provides that particular resource to client and
2. Server is not able to find what client asked for.
But in both cases server has to respond and I am sure that you have seen ‘404 not found’ error whenever you have tried to open a page and server didn’t find that page.

Whenever server sends a response, it sends some types of content (set of instruction written in HTML) and through HTTP.HTML tells the browser how to represent the content sent by server to user.

When browser sends a request to server for server, the server hands the request not to servlet itself but to container in which servlet is deployed.

Now question is how container handles servlet? Let’s see.

When a client send a request to server container sees that request is for servlet and then creates two objects HttpServletResponse and HttpServletRequest. The container finds the correct servlet and creates a thread for that request but before passes the request and response object to the servlet thread, it passes to filter chain to intercepts and process the request .The servlet is having no knowledge of filter. After filtering the request the container passes the request and response object to the servlet thread and calls the service () of servlet depending on the type of request. Thread completes and converts the response object to HTTP Response and sends back to the filter chain and again filter chain process the response and response sends to the client, then delete the request and response object.

Note: Request filter can perform security checks, reformat the request header and body and audit or log request. Response filter can compress the response stream and creates a different response altogether.

No comments:

Copyright © Codingnodes,2014.All Rights Reserved.