DEV Community

Cover image for How spring boot application work as web application
Amit Tiwary
Amit Tiwary

Posted on

How spring boot application work as web application

Spring boot has everything to create a web application and makes web application development fast and hassle-free. The embedded server makes web application creation easy in Spring boot. If embedded server doesn't exist, then we required to install web server like tomcat and deploy application there. After that, only we can use our Java application as web application. But with the help of embedded server, when we create the deployable unit of application i.e JAR, web-server becomes part of it.

Tomcat is the default embedded server for the Spring boot application. So we don't need to do anything to add tomcat in our Spring boot application because it comes with spring boot starter web.

<dependency>

 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-web</artifactId>

</dependency>
Enter fullscreen mode Exit fullscreen mode

If any client makes a request to our Java server, tomcat handles the request.This functionality is made possible by the HTTP Connector element. Two important attributes of HTTP connector are protocol and SSLEnabled. The protocol attribute defines the protocol the connector will use to communicate and bydefault set to HTTP/1.1. SSLEnabled attribute helps connector to decide to use SSL handshake/encryption/decryption. Tomcat has more than one HTTP connector, and we can use anyone. In this blog we will talk about NIO connector.

The NIO connector do non blocking I/O. NIO connector has two thread pools, one holds the poller thread, and other holds the worker thread. Whenever a client makes a request to our Java server, NIO connector uses a thread from poller thread pool and keeps the connection alive. It push these request to handle by the thread from worker threads. Size of both pools are configurable.

Oldest comments (0)