Friday, September 1, 2017

How Client server communication works

The contents(files) that get exchanged between client(browser) and a sever(webserver) are html, css, javascript, images, pdf files etc. When a browser sends a request for a URL, the response can be html or html+css or html+css+javascript. Server wont send all the files in a single response if altogether makes it a large response. Rather it(here 'it' means server which in turn is nothing but the code(Java or c#.NET) written by developer...the way he intends to send) includes links to css,js files, images and other htmls in the response and sends it at the first time. Then server waits for another request to serve the rest of the content. After browser receives the first html response, it sends requests for other resources which are included as links while parsing the first html.
Server then responds with rest of the content.

So far so good. As long as server needs to send only static content, we can have all the html, css and Javascript readily developed to serve them immediately upon request. But, it is not always the case. In fact it never be one. The requests need to be processed based on the business logic and html content has to be rendered with some data retrieved from the database. 
In such case, we need to build html embedding data along with frontend event-handling code and Styling information dynamically.

Below are the techniques to dynamically render html+css+javascript+data:
1) Servlets: These are Java classes which create dynamic webpages by Println statements
2) JSP: A special kind of servlets which embed javacode inside html tags.
3) JSF: Yet another J2EE standard mechanism to handle requests

Ultimately, all such techniques create html response with backend data embedded. And necessary CSS and Javascript is obviously part of it.

No comments:

How J2EE components work together in any Container - Spring or Application Server

In a Spring+Jersey+Hibernate RESTful webapplication, we can spot various J2EE components - JTA, JPA, Java Bean Validation, JSON-B API for B...