Last active
March 4, 2017 16:04
-
-
Save pgordon9/d2cb0fa7da95e1a8e0ae37722d0cd61c to your computer and use it in GitHub Desktop.
IncrementServlet. JettyExample | parkergordon.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse} | |
object JettyExample{ | |
{...} | |
object CounterServlets{ | |
private var requestCount: Int = AtomicInteger(0) | |
class IncrementServlet extends HttpServlet { | |
override protected def doGet(request: HttpServletRequest, response: HttpServletResponse):Unit = { | |
requestCount.getAndIncrement() | |
response.setContentType("text/html") | |
response.setStatus(HttpServletResponse.SC_OK) | |
response.getWriter().println(s"<h2>Increment performed. Count is now $requestCount.</h2>") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment