Kotlin is a great fit for developing server-side applications.
You can write concise and expressive code while maintaining full compatibility with Java. - https://kotlinlang.org/

In software industry server side application development play very important role to solve complex problem and achieve business requirement  in various Industry like Banking, Transport etc.

Java servlet provides server side development  with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are server-side Java EE components that generate responses to requests from clients.

Typical implementations of these APIs on Application servers or servlet containers use a standard servlet for handling all interactions with the HTTP requests and responses that delegate to the web service methods for the actual business logic.

Kotlin is write selection for every where , Kotlin good for Mobile cross-platform, Data Science, Server side based application.  support or Kotlin is great language for server side application development.

In this tutorial we will walks through the process of creating a simple controller using HttpServlet to display Hello Kotlin School.

Java EE Http servlets can be used from Kotlin much like any other Java library or framework. We'll see how to make a simple controller that returns "Hello, Kotlin School.!".

with kotlin we are use gradle with IntelliJ Gradle project structure.  The following two dependency required for HTTP Servlet API.

Creating Web Applications with Http Servlets

buildscript {
    ext.kotlin_version = '1.3.72'
    
}
dependencies {
    compile group: 'javax', name: 'javaee-api', version: '7.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

To generate war file required war  plugin

apply plugin: 'war'

Welcome Controller

@WebServlet(name = "Welcome", value = ["/welcome"])
class WelcomeController : HttpServlet() {
    override fun doGet(req: HttpServletRequest, res: HttpServletResponse) {
        res.writer.write("Hello, Kotlin School!")
    }
}

Using IntelliJ IDEA you can easily run and debug the application in any of the possible application servers defined such as Tomcat, Glassfish or WildFly.

Server side frameworks using Kotlin.

In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. It provides a standard way to build and deploy applications and is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions. Software frameworks may include support programs, compilers, code libraries, tool sets, and application programming interfaces (APIs) that bring together all the different components to enable development of a project or system.

- wikipedia

In JavaEE most popular framework are Sprint, JSF, Hibernate, Struts.

In Kotlin Ktor is a multiplatform toolkit built by JetBrains for creating server side applications. It makes use of coroutines for high scalability and offers an easy-to-use API.

Ktor Applications can be hosted in any servlet container with Servlet 3.0+ API support such as Tomcat, or standalone using Netty or Jetty. Support for other hosts can be added through the unified hosting API.

Hello Ktor!

  • Set up a Ktor project
  • Hello World
  • Accessing Hello Ktor application

Using Gradle and IntelliJ IDE Ktor setup is easy or you can create Ktor project using Ktor Generator .

Now create project using Intellij IDE Plugin. here first step is install plugin in Intellij IDE.

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

@kotlin.jvm.JvmOverloads

This is Kotlin Standard Library Annotation comes under Package kotlin.jvm.

Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values.

Defining Routes

In Ktor, a Route defines a path to your server. This could be an API, like the one you’re creating, or your home page. Ktor uses GET/POST/PUT/DELETE/REST along with a path. For example: