title: Receiving form params to Ktor server
body: <p>I'm new to Java and Kotlin, trying to build a contact form with <code>Ktor</code>, so I enabled the insecure connection of my gmail from <a href="https://myaccount.google.com/lesssecureapps?pli=1" rel="nofollow noreferrer">here</a>, and built the app below:</p>
  
  <p><code>blogApp.kt</code>:</p>
  
  <pre><code>package blog
  
  import org.jetbrains.ktor.netty.*
  import org.jetbrains.ktor.routing.*
  import org.jetbrains.ktor.application.*
  import org.jetbrains.ktor.features.*
  import org.jetbrains.ktor.host.*
  import org.jetbrains.ktor.http.*
  import org.jetbrains.ktor.response.*
  
  import org.apache.commons.mail.*
  
  fun Application.module() {
      install(DefaultHeaders)
      install(CallLogging)
      install(Routing) {
          get("/") {
              call.respondText("""
              My Example Blog2
                  &lt;form action="/contact-us" method="post"&gt;
                      &lt;input name="subject" placeholder="Subject"&gt;
                      &lt;br&gt;
                      &lt;textarea name="message" placeholder="Your message ..."&gt;&lt;/textarea&gt;
                      &lt;br&gt;
                      &lt;button&gt;Submit&lt;/button&gt;
                  &lt;/form&gt;
              """, ContentType.Text.Html)
          }
          post("/contact-us") {
              SimpleEmail().apply {
                  setHostName("smtp.gmail.com")
                  setSmtpPort(465)
                  setAuthenticator(DefaultAuthenticator("my_alias@gmail.com", "my_gmil_passoword"))
                  setSSLOnConnect(true)
                  setFrom("my_alias@gmail.com")
                  setSubject("subject")        // I need to use formParam
                  setMsg("message")            // I need to use formParam
                  addTo("my_alias@gmail.com")
              }.send() // will throw email-exception if something is wrong
              call.respondRedirect("/contact-us/success")
          }
          get("/contact-us/success") { 
              call.respondText("Your message was sent", ContentType.Text.Html) 
          }
      }
  }
  
  fun main(args: Array&lt;String&gt;) {
      embeddedServer(Netty, 8080, watchPaths = listOf("BlogAppKt"), module = Application::module).start()
  }
  </code></pre>
  
  <p><code>build.gradle</code>:</p>
  
  <pre><code>group 'Example'
  
  version 'alpha'
  
  buildscript {
      ext.kotlin_version = '1.1.4-3'
  
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'kotlin'
  
  sourceCompatibility = 1.8
  ext.ktor_version = '0.4.0'
  
  repositories {
      mavenCentral()
      maven { url  "http://dl.bintray.com/kotlin/ktor" }
      maven { url "https://dl.bintray.com/kotlin/kotlinx" }
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
      compile "org.jetbrains.ktor:ktor-core:$ktor_version"
      compile "org.jetbrains.ktor:ktor-netty:$ktor_version"
      compile "org.apache.commons:commons-email:1.4"
      compile "org.slf4j:slf4j-simple:1.7.25"
      compile "ch.qos.logback:logback-classic:1.2.1"
      testCompile group: 'junit', name: 'junit', version: '4.12'
  }
  
  compileKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  compileTestKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  kotlin {
      experimental {
          coroutines "enable"
      }
  }
  
  
  jar {
      baseName 'abc'
      manifest {
          attributes 'Main-Class': 'blog.BlogAppKt'
      }
  
      from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
  }
  </code></pre>
  
  <p>and things gone smoothly with it, I was able to send an email to myself then redirect to the success page, but the message got sent is with pre-set data:</p>
  
  <pre><code>        setSubject("subject")        // I need to use formParam
          setMsg("message")            // I need to use formParam
  </code></pre>
  
  <p>how can I make the <code>Ktor</code> receive the data the user really entered in the form, how can I read the form params?</p>