154 val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" |
155 val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" |
155 |
156 |
156 init { |
157 init { |
157 request.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref) |
158 request.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref) |
158 } |
159 } |
159 |
|
160 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) |
|
161 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") |
|
162 |
160 |
163 fun paramIndexed(prefix: String): Map<Int, String> = buildMap { |
161 fun paramIndexed(prefix: String): Map<Int, String> = buildMap { |
164 for (name in request.parameterNames) { |
162 for (name in request.parameterNames) { |
165 if (name.startsWith(prefix)) { |
163 if (name.startsWith(prefix)) { |
166 val key = name.substring(prefix.length).toIntOrNull() |
164 val key = name.substring(prefix.length).toIntOrNull() |
201 val body: String by lazy { |
199 val body: String by lazy { |
202 request.reader.lineSequence().joinToString("\n") |
200 request.reader.lineSequence().joinToString("\n") |
203 } |
201 } |
204 |
202 |
205 private fun forward(jsp: String) { |
203 private fun forward(jsp: String) { |
206 request.getRequestDispatcher(jspPath(jsp)).forward(request, response) |
204 request.setAttribute(Constants.REQ_ATTR_JSP, jsp) |
207 } |
205 } |
208 |
206 |
209 fun renderFeed(page: String? = null) { |
207 fun renderFeed(page: String? = null) { |
210 page?.let { contentPage = it } |
208 page?.let { contentPage = it } |
211 forward("feed") |
209 forward("feed") |