From f35f3d35fa5840f08e740a1a75b571996b804162 Mon Sep 17 00:00:00 2001 From: Suren Konathala Date: Tue, 10 Apr 2018 15:23:29 -0500 Subject: [PATCH] updates files --- .../servlet-web-applications-maven/.gitignore | 2 + .../servlet-web-applications-maven/ReadMe.md | 45 ++++++++ .../servlet-web-applications-maven/pom.xml | 105 ++++++++++++++++++ .../src/main/kotlin/HomeController.kt | 13 +++ 4 files changed, 165 insertions(+) create mode 100644 tutorials/servlet-web-applications-maven/.gitignore create mode 100644 tutorials/servlet-web-applications-maven/ReadMe.md create mode 100644 tutorials/servlet-web-applications-maven/pom.xml create mode 100644 tutorials/servlet-web-applications-maven/src/main/kotlin/HomeController.kt diff --git a/tutorials/servlet-web-applications-maven/.gitignore b/tutorials/servlet-web-applications-maven/.gitignore new file mode 100644 index 0000000000..c5078494ed --- /dev/null +++ b/tutorials/servlet-web-applications-maven/.gitignore @@ -0,0 +1,2 @@ +target +.idea diff --git a/tutorials/servlet-web-applications-maven/ReadMe.md b/tutorials/servlet-web-applications-maven/ReadMe.md new file mode 100644 index 0000000000..0d1800f9a9 --- /dev/null +++ b/tutorials/servlet-web-applications-maven/ReadMe.md @@ -0,0 +1,45 @@ +# Kotlin Servlet Web Application Example With Maven + +This example is a **maven** version of **servlet-web-applications** example built using gradle. + +Since this example illustrates the use of a REST endpoint, you will need to run this on a web application server. + +## Prerequisites to running the example + + * download Maven directly from the [Apache Maven homepage](http://maven.apache.org/download.html) + * install and configure your system as described in [the installation section](http://maven.apache.org/download.html#Installation) + +## Folder Structure + +Sources + + /src/main/kotlin + +Build/War File + + /target/kotlin-test-servlets.war + + +## Compiling/Building the example's war file + +If you have maven on your path, type: + + mvn clean package + +This will compile: + * src/main/kotlin/HomeController.kt and builds a war file named **kotling-test-servlets.war** into **/target** folder + + +## Running the example's war file + +Once you compiled the sources with previous 'mvn clean package' command, you can see the 'war' file under '/target' folder. + +Now copy the 'war' file and deploy to any web application server like Tomcat, Jetty etc. + +After the deployment is done successfully, open a browser and point to a url like this + + http://localhost:8080/kotlin-test-servlets/hello + +You should see an output as below: + + Hello, World! \ No newline at end of file diff --git a/tutorials/servlet-web-applications-maven/pom.xml b/tutorials/servlet-web-applications-maven/pom.xml new file mode 100644 index 0000000000..22f2fdb8fb --- /dev/null +++ b/tutorials/servlet-web-applications-maven/pom.xml @@ -0,0 +1,105 @@ + + + + 4.0.0 + + org.jetbrains.kotlin.examples + servlet-web-applications-maven + 1.0-SNAPSHOT + war + + + 1.0.3 + 1.8 + 4.12 + UTF-8 + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + junit + junit + ${junit.version} + test + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + javax + javaee-api + 7.0 + provided + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + compile + + compile + + + + src/main/kotlin + src/main/resources + + + + + test-compile + test-compile + + test-compile + + + + src/test/kotlin + src/test/resources + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + kotlin-test-servlets + false + + + + + diff --git a/tutorials/servlet-web-applications-maven/src/main/kotlin/HomeController.kt b/tutorials/servlet-web-applications-maven/src/main/kotlin/HomeController.kt new file mode 100644 index 0000000000..475e05a9b8 --- /dev/null +++ b/tutorials/servlet-web-applications-maven/src/main/kotlin/HomeController.kt @@ -0,0 +1,13 @@ +package org.jetbrains.kotlin.demo + +import javax.servlet.annotation.WebServlet +import javax.servlet.http.HttpServlet +import javax.servlet.http.HttpServletRequest +import javax.servlet.http.HttpServletResponse + +@WebServlet(name = "Hello", value = "/hello") +class HomeController : HttpServlet() { + override fun doGet(req: HttpServletRequest, res: HttpServletResponse) { + res.writer.write("Hello, World!") + } +} \ No newline at end of file