src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt

changeset 374
34abadbdd0e3
parent 367
0a9065936aac
--- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt	Sun May 18 13:24:55 2025 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt	Wed May 21 14:19:07 2025 +0200
@@ -68,7 +68,8 @@
     var contentPage = ""
         set(value) {
             field = value
-            request.setAttribute(Constants.REQ_ATTR_CONTENT_PAGE, jspPath(value))
+            request.setAttribute(Constants.REQ_ATTR_CONTENT_PAGE,
+                Constants.JSP_PATH_PREFIX + value + ".jsp")
         }
 
     /**
@@ -91,7 +92,7 @@
         set(value) {
             field = value
             request.setAttribute(Constants.REQ_ATTR_STYLESHEET,
-                value.map { it.withExt(".css") }
+                value.map { "$it.css" }
             )
         }
 
@@ -104,7 +105,7 @@
         set(value) {
             field = value
             request.setAttribute(Constants.REQ_ATTR_JAVASCRIPT,
-                value.withExt(".js")
+                "$value.js"
             )
         }
 
@@ -157,9 +158,6 @@
         request.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref)
     }
 
-    private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext)
-    private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp")
-
     fun paramIndexed(prefix: String): Map<Int, String> = buildMap {
         for (name in request.parameterNames) {
             if (name.startsWith(prefix)) {
@@ -203,7 +201,7 @@
     }
 
     private fun forward(jsp: String) {
-        request.getRequestDispatcher(jspPath(jsp)).forward(request, response)
+        request.setAttribute(Constants.REQ_ATTR_JSP, jsp)
     }
 
     fun renderFeed(page: String? = null) {

mercurial