Tuomas Toivonen
Tuomas Toivonen

Reputation: 23492

How does Java Servlet works in the OSI model

How does Java Servlet and container actually works at each layer of Open Systems Interconnection model (OSI model)? Does the servlet container internally use operating system's native socket libraries via JNI? Is there even any other possibility for JVM to use networking?

Upvotes: 1

Views: 876

Answers (1)

Pedro Pinheiro
Pedro Pinheiro

Reputation: 1069

The OSI model works great in theory as a guideline, but in practice is not always possible or easy to classify or separate the inner workings and protocols of a complex system in each of its layers. To better understand the protocol architecture of, for instance, a Java Servlet, it is much better to use the TCP/IP model since it is simpler than the OSI model.

the TCP/IP model

Starting with the Link Layer, it has the task to translate an IP address to a MAC or physical address. The most famous protocol in this layer is the Ethernet. It mainly operates inside an Ethernet network card.

Next we have the Network and the Transport Layer, where we find the IP and TCP protocols, respectively. Both protocols are usually supported by the host operating system using a networking application programming interface (API). The most popular API is called sockets. In the case of Java, its objects have an underlying implementation that interfaces to native code (according to these sources: 1, 2, and 3).

And finally there's the Application layer, where we find the HTTP protocol. This protocol is implemented and supported by the application servers, such as Tomcat, JBoss and Glassfish.

Reference: This answer was based on the book TCP/IP Illustrated book, by Kevin R. Fall

Upvotes: 1

Related Questions