{"id":39584740,"url":"https://github.com/arnolddevos/JettyS","last_synced_at":"2026-01-26T15:01:18.095Z","repository":{"id":873307,"uuid":"614393","full_name":"arnolddevos/JettyS","owner":"arnolddevos","description":"Scala API for servlets in general and Jetty in particular","archived":false,"fork":false,"pushed_at":"2010-08-11T05:16:14.000Z","size":103,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T16:07:29.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnolddevos.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-04-16T23:48:29.000Z","updated_at":"2015-10-01T21:19:09.000Z","dependencies_parsed_at":"2022-08-16T11:15:24.267Z","dependency_job_id":null,"html_url":"https://github.com/arnolddevos/JettyS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arnolddevos/JettyS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnolddevos%2FJettyS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnolddevos%2FJettyS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnolddevos%2FJettyS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnolddevos%2FJettyS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnolddevos","download_url":"https://codeload.github.com/arnolddevos/JettyS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnolddevos%2FJettyS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28781308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-18T07:35:27.100Z","updated_at":"2026-01-26T15:01:18.083Z","avatar_url":"https://github.com/arnolddevos.png","language":"Scala","readme":"The aim of this pimped servlet API is to add the minimum to javax.servlet to\nscalaize it. There is no routing engine, no ORM layer, just the usual scala \npimping techniques. \n\nOne good idea is to recast the servlet service methods as:\n\nHttpServletRequest =\u003e HttpServletResponse =\u003e Unit\n\nThe HttpServletResponse =\u003e Unit part can then be factored into stock\nobjects called Responders. You can then concentrate on the \nHttpServletRequest =\u003e Responder part.\n\nThe result is not too shabby. It lets you write hello world like this: \n\nget(\"/\") { \n    request =\u003e \u003ch1\u003eHello {request(\"yourname\") getOrElse \"stranger\"}!\u003c/h1\u003e\n}\n\nHere the request is implicitly wrapped to allow easy parameter access\nas in request(\"yourname\") and the result, a scala.xml.Node, is implicitly \nconverted to a suitable Responder.\n\nOK, to be fair, lets expand that out with all the imports and proper XHTML:\n\npackage example\nimport au.com.langdale.webserver._\nimport Driver._       // start and stop Jetty\nimport Connectors._   // Jetty-specific connection methods such as listen()\nimport Handlers._     // Jetty-specific binding methods get(\"...\") and post(\"...\")\nimport Responders._   // generic responders and implicit conversions for responses\nimport Requests._     // generic request extractors and wrapper \n\nobject HelloWorld {\n  val host = \"127.0.0.1\"\n  val port = 9986\n  \n  // tell Jetty where to receive connections\n  listen(host, port)\n\n  // may be omitted since this is the default for XML responses\n  implicit val contentType = ContentType(\"application/xhtml+xml\")\n  \n  // hello world server\n  get(\"/test\") { request =\u003e\n    \u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\n      \u003chead\u003e\u003ctitle\u003eThe Test Page\u003c/title\u003e\u003c/head\u003e\n      \u003cbody\u003e\n        \u003ch1\u003eTest\u003c/h1\u003e\n        \u003cp\u003eHello {request(\"yourname\") getOrElse \"stranger\"}!\u003c/p\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n  }\n\n  def main(args: Array[String]) = { start; join }\n}\n\nInstead of querying the (wrapped) HttpServletRequest, you can use pattern matching.\nHere is a KML service for google earth that shows this:\n\nimplicit val contentType = ContentType(\"application/vnd.google-earth.kml+xml\")\n// note 1\n\nget(\"/cafe\") {\n  case Params(BBox(w, s, e, n)) =\u003e   // note 2\n    \u003ckml xmlns=\"http://www.opengis.net/kml/2.2\"\u003e\n      \u003cDocument\u003e\n      {  \n        for((name, lon, lat) \u003c- findCafesIn(w, s, e, n)) yield\n        \u003cPlacemark\u003e\n          \u003cname\u003e{name}\u003c/name\u003e\n          \u003cPoint\u003e\n            \u003ccoordinates\u003e{lon},{lat},0\u003c/coordinates\u003e\n          \u003c/Point\u003e\n        \u003c/Placemark\u003e\n      }\n      \u003c/Document\u003e\n    \u003c/kml\u003e\n      \n  case _ =\u003e 404 // note 3\n} \n\nThe example extracts the coordinates of a bounding box (w, s, e, n) from a\nGoogle Earth request and uses them to find a collection of locations via\nfindCafes(..), which is supposedly a spatial query on some data source.  \n\nThe locations are wrapped in KML markup and returned. \n\nThis shows how to:\n\n * set an implicit content type (note 1); \n * use extractors to obtain request parameters (note 2); \n * implicitly convert responses such as XML or integers. \n   e.g an integer gets converted to an error response (note 3). \n\nThere is a longer writeup here: http://notes.langdale.com.au/Pimping_Servlet_and_Jetty.html","funding_links":[],"categories":["\u003ca name=\"Scala\"\u003e\u003c/a\u003eScala"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnolddevos%2FJettyS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnolddevos%2FJettyS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnolddevos%2FJettyS/lists"}