diff --git a/LICENSE b/LICENSE index 04f9efeefb..c535c05435 100644 --- a/LICENSE +++ b/LICENSE @@ -244,7 +244,6 @@ SECTION 2: Apache License, V2.0 >>> jansi-1.11 >>> jsp-api-2.0 >>> log4j-1.2.17 - >>> sitemesh-3.1.1 >>> spring-aop-4.0.4 >>> spring-aspects-4.0.4 >>> spring-beans-4.0.4 diff --git a/build.gradle b/build.gradle index b217bf8523..4993247830 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,8 @@ buildscript { } repositories { - mavenLocal() + //mavenLocal() + mavenCentral() maven { url "https://repo.grails.org/grails/core" } } @@ -45,8 +46,9 @@ subprojects { } repositories { - mavenLocal() - maven { url "https://repo.grails.org/grails/core" } + //mavenLocal() + mavenCentral() + maven { url = "https://repo.grails.org/grails/core" } } if (it.name.startsWith("examples")) { @@ -68,6 +70,14 @@ subprojects { targetCompatibility=1.17 configurations.all { + + // FORCE UPGRADE OF GROOVY IN DEPENDENCIES TO GROOVY 4 + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + if (details.requested.group == 'org.codehaus.groovy') { + details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion) + } + } + resolutionStrategy.eachDependency { DependencyResolveDetails details -> if (details.requested.group == "org.spockframework") { details.useVersion(spockVersion) @@ -80,9 +90,9 @@ subprojects { } dependencies { - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" + compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" - testImplementation "javax.servlet:javax.servlet-api:$servletApiVersion" + testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" testImplementation "org.codehaus.groovy:groovy-test-junit5:${groovyVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" testImplementation "org.junit.platform:junit-platform-runner:${junitPlatformVerison}" diff --git a/gradle.properties b/gradle.properties index fe05c6fb3c..5b3f7d846a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,17 +7,20 @@ githubSlug=grails/grails-gsp githubBranch=7.0.x developers=Puneet Behl, Graeme Rocher grailsGradlePluginVersion=6.2.0 -grailsVersion=6.2.0 -groovyVersion=3.0.21 -servletApiVersion=4.0.1 +grailsVersion=7.0.0-SNAPSHOT +groovyVersion=4.0.22 +annotationApiVersion=3.0.0 +byteBuddyVersion=1.14.18 +elApiVersion=6.0.1 +servletApiVersion=6.0.0 javaParserCoreVersion=3.15.14 jansiVersion=1.18 jlineVersion=2.14.6 -jspApiVersion=2.1 -jstlVersion=1.1.2 +jspApiVersion=4.0.0 +jstlVersion=3.0.0 junitJupiterVersion=5.10.2 junitPlatformVerison=1.10.2 -spockVersion=2.0-groovy-3.0 +spockVersion=2.3-groovy-4.0 slf4jVersion=1.7.32 antVersion=1.10.14 controllersRef=https://docs.grails.org/latest/ref/Controllers diff --git a/grails-gsp/build.gradle b/grails-gsp/build.gradle index fdd2910d32..e8dc776dae 100644 --- a/grails-gsp/build.gradle +++ b/grails-gsp/build.gradle @@ -3,5 +3,5 @@ dependencies { exclude group:'org.grails', module:'grails-spring' } api project(":grails-taglib") - api "org.codehaus.groovy:groovy-templates:$groovyVersion" + api "org.apache.groovy:groovy-templates:$groovyVersion" } diff --git a/grails-gsp/src/main/groovy/org/grails/gsp/ModelRecordingGroovyPage.groovy b/grails-gsp/src/main/groovy/org/grails/gsp/ModelRecordingGroovyPage.groovy index 7302ec004e..5faeab8283 100644 --- a/grails-gsp/src/main/groovy/org/grails/gsp/ModelRecordingGroovyPage.groovy +++ b/grails-gsp/src/main/groovy/org/grails/gsp/ModelRecordingGroovyPage.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -143,10 +143,10 @@ class ModelRecordingCache { class ModelEntry { // defaults are defined by org.grails.web.taglib.WebRequestTemplateVariableBinding static Map DEFAULT_TYPES = [webRequest : 'org.grails.web.servlet.mvc.GrailsWebRequest', - request : 'javax.servlet.http.HttpServletRequest', - response : 'javax.servlet.http.HttpServletResponse', + request : 'jakarta.servlet.http.HttpServletRequest', + response : 'jakarta.servlet.http.HttpServletResponse', flash : 'grails.web.mvc.FlashScope', - application : 'javax.servlet.ServletContext', + application : 'jakarta.servlet.ServletContext', applicationContext: 'org.springframework.context.ApplicationContext', grailsApplication : 'grails.core.GrailsApplication', session : 'grails.web.servlet.mvc.GrailsHttpSession', @@ -155,7 +155,7 @@ class ModelEntry { controllerName : 'CharSequence'] Map model = Collections.synchronizedMap([:]) - Set taglibs = Collections.synchronizedSet([] as Set) + Set taglibs = Collections.synchronizedSet([] as Set) Set defaultTagLibs = new HashSet(GroovyPageParser.DEFAULT_TAGLIB_NAMESPACES) int initialSize @@ -184,7 +184,7 @@ class ModelEntry { if(defaultType) { try { // use default field type for if field type is instance of the class - // for example instance of 'org.apache.catalina.core.ApplicationHttpRequest', use 'javax.servlet.http.HttpServletRequest' + // for example instance of 'org.apache.catalina.core.ApplicationHttpRequest', use 'jakarta.servlet.http.HttpServletRequest' Class fieldTypeClass = Class.forName(fieldType) Class defaultTypeClass = Class.forName(defaultType) if (defaultTypeClass.isAssignableFrom(fieldTypeClass)) { diff --git a/grails-gsp/src/main/groovy/org/grails/gsp/compiler/GroovyPageParser.java b/grails-gsp/src/main/groovy/org/grails/gsp/compiler/GroovyPageParser.java index 9cf3cd30b8..4942c507fc 100644 --- a/grails-gsp/src/main/groovy/org/grails/gsp/compiler/GroovyPageParser.java +++ b/grails-gsp/src/main/groovy/org/grails/gsp/compiler/GroovyPageParser.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,7 +15,6 @@ */ package org.grails.gsp.compiler; -import grails.config.Config; import grails.config.ConfigMap; import grails.io.IOUtils; import grails.util.Environment; @@ -141,7 +140,6 @@ public class GroovyPageParser implements Tokens { public static final String CONFIG_PROPERTY_GSP_ENCODING = "grails.views.gsp.encoding"; public static final String CONFIG_PROPERTY_GSP_KEEPGENERATED_DIR = "grails.views.gsp.keepgenerateddir"; - public static final String CONFIG_PROPERTY_GSP_SITEMESH_PREPROCESS = "grails.views.gsp.sitemesh.preprocess"; public static final String CONFIG_PROPERTY_GSP_COMPILESTATIC = "grails.views.gsp.compileStatic"; public static final String CONFIG_PROPERTY_GSP_ALLOWED_TAGLIB_NAMESPACES = "grails.views.gsp.compileStaticConfig.taglibs"; public static final String CONFIG_PROPERTY_GSP_CODECS = "grails.views.gsp.codecs"; diff --git a/grails-plugin-gsp/build.gradle b/grails-plugin-gsp/build.gradle index 7b64b74ed7..723e5df6a4 100644 --- a/grails-plugin-gsp/build.gradle +++ b/grails-plugin-gsp/build.gradle @@ -14,7 +14,7 @@ configurations.all { } } dependencies { - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" + compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" api project(":grails-web-gsp-taglib") runtimeOnly(project(":grails-web-jsp")) @@ -34,9 +34,10 @@ dependencies { } testRuntimeOnly "org.grails.plugins:async" - testImplementation "javax.servlet.jsp:jsp-api:${jspApiVersion}" - testImplementation "taglibs:standard:${jstlVersion}" - testImplementation "javax.servlet:jstl:${jstlVersion}" + testImplementation "jakarta.annotation:jakarta.annotation-api:$annotationApiVersion" + testImplementation "jakarta.servlet.jsp:jakarta.servlet.jsp-api:${jspApiVersion}" + testRuntimeOnly "org.glassfish.web:jakarta.servlet.jsp.jstl:${jstlVersion}" + testImplementation "jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:${jstlVersion}" testRuntimeOnly "org.grails:grails-plugin-url-mappings:$grailsVersion" } diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy index ed4db7e2c1..a41df58295 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,6 +14,7 @@ * limitations under the License. */ package org.grails.plugins.web + import grails.config.Config import grails.core.gsp.GrailsTagLibClass import grails.gsp.PageRenderer @@ -58,9 +59,6 @@ class GroovyPagesGrailsPlugin extends Plugin { public static final String GSP_RELOAD_INTERVAL = "grails.gsp.reload.interval" public static final String GSP_VIEWS_DIR = 'grails.gsp.view.dir' - public static final String GSP_VIEW_LAYOUT_RESOLVER_ENABLED = 'grails.gsp.view.layoutViewResolver' - public static final String SITEMESH_DEFAULT_LAYOUT = 'grails.sitemesh.default.layout' - public static final String SITEMESH_ENABLE_NONGSP = 'grails.sitemesh.enable.nongsp' def watchedResources = ["file:./plugins/*/grails-app/taglib/**/*TagLib.groovy", "file:./grails-app/taglib/**/*TagLib.groovy"] @@ -111,16 +109,9 @@ class GroovyPagesGrailsPlugin extends Plugin { long gspCacheTimeout = config.getProperty(GSP_RELOAD_INTERVAL, Long, (developmentMode && env == Environment.DEVELOPMENT) ? 0L : 5000L) boolean enableCacheResources = !config.getProperty(GroovyPagesTemplateEngine.CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES, Boolean, false) String viewsDir = config.getProperty(GSP_VIEWS_DIR, '') - boolean enableLayoutViewResolver = config.getProperty(GSP_VIEW_LAYOUT_RESOLVER_ENABLED, Boolean, true) - String defaultDecoratorNameSetting = config.getProperty(SITEMESH_DEFAULT_LAYOUT, '') - def sitemeshEnableNonGspViews = config.getProperty(SITEMESH_ENABLE_NONGSP, Boolean, false) - - RuntimeSpringConfiguration spring = springConfig - - // resolves JSP tag libraries if(ClassUtils.isPresent("org.grails.gsp.jsp.TagLibraryResolverImpl", application.classLoader)) { jspTagLibraryResolver(TagLibraryResolverImpl) @@ -230,7 +221,7 @@ class GroovyPagesGrailsPlugin extends Plugin { } boolean jstlPresent = ClassUtils.isPresent( - "javax.servlet.jsp.jstl.core.Config", InternalResourceViewResolver.class.getClassLoader()) + "jakarta.servlet.jsp.jstl.core.Config", InternalResourceViewResolver.class.getClassLoader()) abstractViewResolver { prefix = GrailsApplicationAttributes.PATH_TO_VIEWS diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/ApplicationTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/ApplicationTagLib.groovy index b8e2849b35..af6b0a7f41 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/ApplicationTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/ApplicationTagLib.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -27,7 +27,6 @@ import grails.util.GrailsStringUtils import grails.plugins.GrailsPluginManager import grails.core.support.GrailsApplicationAware import grails.web.mapping.LinkGenerator -import grails.web.mapping.UrlMapping import grails.web.mapping.UrlMappingsHolder import org.grails.web.servlet.mvc.GrailsWebRequest import org.codehaus.groovy.runtime.InvokerHelper @@ -37,8 +36,8 @@ import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware import org.springframework.web.servlet.support.RequestDataValueProcessor -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse /** * The base application tag library for Grails many of which take inspiration from Rails helpers (thanks guys! :) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/JavascriptTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/JavascriptTagLib.groovy index d7fe839d7a..bb661915e7 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/JavascriptTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/JavascriptTagLib.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import grails.plugins.GrailsPluginManager import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware -import javax.annotation.PostConstruct +import jakarta.annotation.PostConstruct /** * Javascript tags. diff --git a/grails-plugin-gsp/src/test/groovy/grails/util/MockRequestDataValueProcessor.groovy b/grails-plugin-gsp/src/test/groovy/grails/util/MockRequestDataValueProcessor.groovy index 38d234c2a5..9a16950603 100644 --- a/grails-plugin-gsp/src/test/groovy/grails/util/MockRequestDataValueProcessor.groovy +++ b/grails-plugin-gsp/src/test/groovy/grails/util/MockRequestDataValueProcessor.groovy @@ -2,7 +2,7 @@ package grails.util import org.springframework.web.servlet.support.RequestDataValueProcessor -import javax.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletRequest /** * Created by graemerocher on 12/04/2017. diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPageWithJSPTagsTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPageWithJSPTagsTests.groovy index 6977eb069b..5ec1463a0e 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPageWithJSPTagsTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPageWithJSPTagsTests.groovy @@ -5,10 +5,8 @@ import grails.testing.web.taglib.TagLibUnitTest import grails.web.http.HttpHeaders import org.grails.plugins.web.taglib.ApplicationTagLib import org.grails.web.pages.GroovyPagesServlet -import org.springframework.context.MessageSource -import org.springframework.web.servlet.support.JstlUtils import spock.lang.* -import javax.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletRequest import org.springframework.mock.web.MockHttpServletRequest import org.springframework.core.io.support.PathMatchingResourcePatternResolver @@ -47,7 +45,7 @@ class GroovyPageWithJSPTagsTests extends Specification implements TagLibUnitTest when: //JstlUtils.exposeLocalizationContext(request, grailsApplication.mainContext.getBean("messageSource", MessageSource)) def template = ''' -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="c" uri="jakarta.tags.core" %> .
@@ -112,7 +110,7 @@ class GroovyPageWithJSPTagsTests extends Specification implements TagLibUnitTest def testNestedJSPTags() { when: def template = ''' -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="jakarta.tags.core" prefix="c" %> test @@ -139,7 +137,7 @@ goodbye def testGSPCantOverrideDefaultNamespaceWithJSP() { when: - def template = '<%@ taglib prefix="g" uri="http://java.sun.com/jsp/jstl/fmt" %>' + def template = '<%@ taglib prefix="g" uri="jakarta.tags.fmt" %>' String output = applyTemplate(template) then: @@ -149,7 +147,7 @@ goodbye def testGSPWithIterativeJSPTag() { when: def template = ''' - <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> + <%@ taglib prefix="c" uri="jakarta.tags.core" %>

${num}

''' @@ -162,7 +160,7 @@ goodbye def testSimpleTagWithValue() { when: - def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>' + def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>' String output = applyTemplate(template) then: @@ -171,7 +169,7 @@ goodbye def testInvokeJspTagAsMethod() { when: - def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>${fmt.formatNumber(value:10, pattern:".00")}' + def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>${fmt.formatNumber(value:10, pattern:".00")}' String output = applyTemplate(template) then: @@ -180,7 +178,7 @@ goodbye def testInvokeJspTagAsMethodWithBody() { when: - def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>${fmt.formatNumber(pattern:".00",10)}' + def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>${fmt.formatNumber(pattern:".00",10)}' String output = applyTemplate(template) then: @@ -189,7 +187,7 @@ goodbye def testSimpleTagWithBody() { when: - def template = '<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>10' + def template = '<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>10' String output = applyTemplate(template) then: diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPagesPageContextTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPagesPageContextTests.groovy index 1e7d16ec43..a55b30e437 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPagesPageContextTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/GroovyPagesPageContextTests.groovy @@ -1,18 +1,13 @@ package org.grails.gsp.jsp import grails.util.GrailsWebMockUtil +import jakarta.servlet.jsp.PageContext import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test - -import javax.servlet.jsp.PageContext - import org.springframework.web.context.request.RequestContextHolder -import static org.junit.jupiter.api.Assertions.assertEquals -import static org.junit.jupiter.api.Assertions.assertNull -import static org.junit.jupiter.api.Assertions.assertTrue +import static org.junit.jupiter.api.Assertions.* /** * @author Graeme Rocher diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/SimpleTagTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/SimpleTagTests.groovy index 4959d8698a..b352e37082 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/SimpleTagTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/SimpleTagTests.groovy @@ -2,17 +2,14 @@ package org.grails.gsp.jsp import grails.core.DefaultGrailsApplication import grails.util.GrailsWebMockUtil +import jakarta.servlet.jsp.JspException +import jakarta.servlet.jsp.JspWriter +import jakarta.servlet.jsp.tagext.SimpleTagSupport +import org.grails.web.pages.GroovyPagesServlet +import org.grails.web.servlet.mvc.GrailsWebRequest import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test - -import javax.servlet.jsp.JspException -import javax.servlet.jsp.JspWriter -import javax.servlet.jsp.tagext.SimpleTagSupport - -import org.grails.web.pages.GroovyPagesServlet -import org.grails.web.servlet.mvc.GrailsWebRequest import org.springframework.mock.web.MockServletContext import org.springframework.web.context.request.RequestContextHolder diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/TagLibraryResolverTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/TagLibraryResolverTests.groovy index 2ca061eb4d..9aa6a02756 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/TagLibraryResolverTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/TagLibraryResolverTests.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,51 +17,57 @@ package org.grails.gsp.jsp import grails.core.DefaultGrailsApplication import org.codehaus.groovy.tools.RootLoader -import org.junit.jupiter.api.Test import org.springframework.core.io.ByteArrayResource import org.springframework.core.io.DefaultResourceLoader import org.springframework.core.io.Resource import org.springframework.mock.web.MockServletContext +import spock.lang.Specification -class TagLibraryResolverTests { +class TagLibraryResolverTests extends Specification { - @Test void testResolveTagLibraryFromJar() { + given: def resolver = new TagLibraryResolverImpl() resolver.servletContext = new MockServletContext() resolver.grailsApplication= new DefaultGrailsApplication() - resolver.tldScanPatterns = ['classpath*:/META-INF/fmt.tld', 'classpath*:/META-INF/c-1_0-rt.tld'] as String[] + resolver.tldScanPatterns = ['classpath*:/META-INF/fmt.tld', 'classpath*:/META-INF/c.tld'] as String[] resolver.resourceLoader = new DefaultResourceLoader(this.class.classLoader) - - JspTagLib tagLib = resolver.resolveTagLibrary("http://java.sun.com/jsp/jstl/fmt") - assert tagLib + when: + def tagLib = resolver.resolveTagLibrary('jakarta.tags.fmt') - JspTag messageTag = tagLib.getTag("message") - assert messageTag + then: + tagLib - // when resolving second time the code will take a different branch - // because certain locations have been cached. This test tests that + when: + def messageTag = tagLib.getTag('message') - tagLib = resolver.resolveTagLibrary("http://java.sun.com/jstl/core_rt") + then: + messageTag - assert tagLib + when: + // when resolving second time the code will take a different branch + // because certain locations have been cached. This test tests that + tagLib = resolver.resolveTagLibrary('jakarta.tags.core') - assert tagLib.getTag("redirect") + then: + tagLib + tagLib.getTag('redirect') } - @Test void testResolveTagLibraryFromWebXml() { + given: def resolver = new MockWebXmlTagLibraryResolver() resolver.servletContext = new MockServletContext() resolver.grailsApplication= new DefaultGrailsApplication() - JspTagLib tagLib = resolver.resolveTagLibrary("http://grails.codehaus.org/tags") - - assert tagLib + when: + def tagLib = resolver.resolveTagLibrary('http://grails.codehaus.org/tags') - assert tagLib.getTag("javascript") + then: + tagLib + tagLib.getTag('javascript') } } @@ -73,82 +79,80 @@ class MockWebXmlTagLibraryResolver extends TagLibraryResolverImpl { protected InputStream getTldFromServletContext(String loc) { - assert "/WEB-INF/tld/grails.tld" == loc - - new ByteArrayResource(''' - - The Grails (Groovy on Rails) custom tag library - 0.2 - grails - http://grails.codehaus.org/tags - - - - Includes a javascript src file, library or inline script - if the tag has no src or library attributes its assumed to be an inline script - - javascript - JavascriptTagLib - JSP - - A predefined JavaScript or AJAX library to load - library - false - true - - - A custom (or unknown to Grails) JavaScript source file - src - false - true - - - Since 0.6 Specifies the full base url to prepend to the library name - base - false - true - - false - - - -'''.getBytes()).getInputStream() + assert '/WEB-INF/tld/grails.tld' == loc + + new ByteArrayResource('''\ + | + | + | The Grails (Groovy on Rails) custom tag library + | 0.2 + | grails + | http://grails.codehaus.org/tags + | + | + | + | Includes a javascript src file, library or inline script + | if the tag has no src or library attributes its assumed to be an inline script + | + | javascript + | JavascriptTagLib + | JSP + | + | A predefined JavaScript or AJAX library to load + | library + | false + | true + | + | + | A custom (or unknown to Grails) JavaScript source file + | src + | false + | true + | + | + | Since 0.6 Specifies the full base url to prepend to the library name + | base + | false + | true + | + | false + | + | + |'''.stripMargin().bytes + ).inputStream } protected Resource getWebXmlFromServletContext() { - new ByteArrayResource(''' - - - - - - /@grails.project.key@ - - - - grails - org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet - 2 - - - - gsp - *.gsp - - - - http://grails.codehaus.org/tags - /WEB-INF/tld/grails.tld - - - -'''.getBytes()) + new ByteArrayResource('''\ + | + | + | /@grails.project.key@ + | + | + | + | grails + | org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet + | 2 + | + | + | + | gsp + | *.gsp + | + | + | + | http://grails.codehaus.org/tags + | /WEB-INF/tld/grails.tld + | + | + |'''.stripMargin().bytes + ) } } diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/WebXmlTagLibraryReaderTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/WebXmlTagLibraryReaderTests.groovy index 345b24b3fe..63f6c67fdc 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/WebXmlTagLibraryReaderTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/gsp/jsp/WebXmlTagLibraryReaderTests.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,133 +15,123 @@ */ package org.grails.gsp.jsp +import spock.lang.Specification -import org.junit.jupiter.api.Test +class WebXmlTagLibraryReaderTests extends Specification { -import static org.junit.jupiter.api.Assertions.assertEquals - - -class WebXmlTagLibraryReaderTests { - - @Test void testWebXmlTagLibraryReader() { + given: def is = new ByteArrayInputStream(testWebXml.getBytes()) WebXmlTagLibraryReader webXmlReader = new WebXmlTagLibraryReader(is) - assert webXmlReader.tagLocations - - assertEquals 4, webXmlReader.tagLocations.size() - - def map = webXmlReader.tagLocations - assertEquals map["http://java.sun.com/jstl/core"], "/WEB-INF/tld/c.tld" + expect: + webXmlReader.tagLocations + webXmlReader.tagLocations.size() == 4 + webXmlReader.tagLocations['jakarta.tags.core'] == '/WEB-INF/tld/c.tld' } - def testWebXml = ''' - - - - - - /@grails.project.key@ - - - log4jConfigLocation - /WEB-INF/classes/log4j.properties - - - - contextConfigLocation - /WEB-INF/applicationContext.xml - - - - webAppRootKey - @grails.project.key@ - - - - charEncodingFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - characterEncodingFilter - - - targetFilterLifecycle - true - - - - - charEncodingFilter - /* - - - - log4j - org.springframework.web.util.Log4jConfigServlet - 1 - - - - - context - org.springframework.web.context.ContextLoaderServlet - 1 - - - - - - grails - org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet - 2 - - - - - - gsp - GroovyPagesServlet - - - - gsp - *.gsp - - - - - - index.html - index.jsp - index.gsp - - - - http://java.sun.com/jstl/core - /WEB-INF/tld/c.tld - - - - http://java.sun.com/jstl/fmt - /WEB-INF/tld/fmt.tld - - - - http://www.springframework.org/tags - /WEB-INF/tld/spring.tld - - - - http://grails.codehaus.org/tags - /WEB-INF/tld/grails.tld - - -''' + def testWebXml = '''\ + | + | + | /@grails.project.key@ + | + | + | log4jConfigLocation + | /WEB-INF/classes/log4j.properties + | + | + | + | contextConfigLocation + | /WEB-INF/applicationContext.xml + | + | + | + | webAppRootKey + | @grails.project.key@ + | + | + | + | charEncodingFilter + | org.springframework.web.filter.DelegatingFilterProxy + | + | targetBeanName + | characterEncodingFilter + | + | + | targetFilterLifecycle + | true + | + | + | + | + | charEncodingFilter + | /* + | + | + | + | log4j + | org.springframework.web.util.Log4jConfigServlet + | 1 + | + | + | + | + | context + | org.springframework.web.context.ContextLoaderServlet + | 1 + | + | + | + | + | grails + | org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet + | 2 + | + | + | + | + | gsp + | GroovyPagesServlet + | + | + | + | gsp + | *.gsp + | + | + | + | + | index.html + | index.jsp + | index.gsp + | + | + | + | jakarta.tags.core + | /WEB-INF/tld/c.tld + | + | + | + | jakarta.tags.fmt + | /WEB-INF/tld/fmt.tld + | + | + | + | http://www.springframework.org/tags + | /WEB-INF/tld/spring.tld + | + | + | + | http://grails.codehaus.org/tags + | /WEB-INF/tld/grails.tld + | + | + |'''.stripMargin() } diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/pages/GroovyPageServletSpec.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/pages/GroovyPageServletSpec.groovy index f33064a933..174a9e3af4 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/pages/GroovyPageServletSpec.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/pages/GroovyPageServletSpec.groovy @@ -1,15 +1,11 @@ package org.grails.web.pages -import org.grails.gsp.GroovyPagesTemplateEngine -import org.springframework.context.support.GenericApplicationContext -import org.springframework.web.context.support.GenericWebApplicationContext - -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse - +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.grails.core.io.SimpleMapResourceLoader -import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator +import org.grails.gsp.GroovyPagesTemplateEngine import org.grails.gsp.io.GroovyPageScriptSource +import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator import org.grails.web.servlet.mvc.GrailsWebRequest import org.springframework.core.io.ByteArrayResource import org.springframework.mock.web.MockHttpServletRequest @@ -18,8 +14,8 @@ import org.springframework.mock.web.MockServletConfig import org.springframework.mock.web.MockServletContext import org.springframework.web.context.WebApplicationContext import org.springframework.web.context.request.RequestContextHolder +import org.springframework.web.context.support.GenericWebApplicationContext import org.springframework.web.util.WebUtils - import spock.lang.Specification /** diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ApplicationTagLibTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ApplicationTagLibTests.groovy index 8f524072ad..830801583d 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ApplicationTagLibTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ApplicationTagLibTests.groovy @@ -5,7 +5,7 @@ import grails.util.GrailsUtil import grails.util.Holders import grails.util.Metadata import grails.util.MockRequestDataValueProcessor -import groovy.transform.NotYetImplemented +import groovy.test.NotYetImplemented import org.grails.gsp.GroovyPageBinding import org.grails.plugins.web.taglib.ApplicationTagLib import org.grails.plugins.web.taglib.FormTagLib @@ -14,7 +14,7 @@ import org.grails.web.util.GrailsApplicationAttributes import org.grails.web.util.WebUtils import spock.lang.Specification -import javax.servlet.http.Cookie +import jakarta.servlet.http.Cookie class ApplicationTagLibTests extends Specification implements TagLibUnitTest { diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/SelectTagTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/SelectTagTests.groovy index 55c41df106..f4ebd88092 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/SelectTagTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/SelectTagTests.groovy @@ -1,5 +1,6 @@ package org.grails.web.taglib +import groovy.xml.XmlSlurper import org.apache.commons.lang.WordUtils import org.junit.jupiter.api.Test import org.springframework.context.MessageSourceResolvable diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ValidationTagLibSpec.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ValidationTagLibSpec.groovy index 86ce2d8f3c..a061b58d25 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ValidationTagLibSpec.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/ValidationTagLibSpec.groovy @@ -1,8 +1,24 @@ +/* + * Copyright 2014-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.grails.web.taglib import grails.gorm.annotation.Entity import grails.testing.gorm.DataTest import grails.testing.web.taglib.TagLibUnitTest +import groovy.xml.XmlSlurper import org.grails.core.io.MockStringResourceLoader import org.grails.plugins.web.taglib.ValidationTagLib import org.grails.web.util.GrailsApplicationAttributes @@ -18,22 +34,6 @@ import spock.lang.Specification import java.beans.PropertyEditorSupport -/* - * Copyright 2014 original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /** * @author graemerocher */ diff --git a/grails-plugin-gsp/src/test/resources/org/codehaus/groovy/grails/web/pages/ext/jsp/tld-reader-test.tld b/grails-plugin-gsp/src/test/resources/org/codehaus/groovy/grails/web/pages/ext/jsp/tld-reader-test.tld index 0669550e38..443b60e5fd 100644 --- a/grails-plugin-gsp/src/test/resources/org/codehaus/groovy/grails/web/pages/ext/jsp/tld-reader-test.tld +++ b/grails-plugin-gsp/src/test/resources/org/codehaus/groovy/grails/web/pages/ext/jsp/tld-reader-test.tld @@ -1,9 +1,9 @@ - + xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee + https://jakarta.ee/xml/ns/jakartaee/web-jsptaglibrary_3_0.xsd" + version="3.0"> The Grails (Groovy on Rails) custom tag library 0.2 grails diff --git a/grails-web-gsp-taglib/build.gradle b/grails-web-gsp-taglib/build.gradle index e7deeeaa10..2dd3d86bef 100644 --- a/grails-web-gsp-taglib/build.gradle +++ b/grails-web-gsp-taglib/build.gradle @@ -1,4 +1,4 @@ dependencies { - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" + compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" api project(':grails-web-jsp') } diff --git a/grails-web-gsp-taglib/src/main/groovy/org/grails/plugins/web/taglib/RenderTagLib.groovy b/grails-web-gsp-taglib/src/main/groovy/org/grails/plugins/web/taglib/RenderTagLib.groovy index 4d8b36cfd6..b92e1e360f 100644 --- a/grails-web-gsp-taglib/src/main/groovy/org/grails/plugins/web/taglib/RenderTagLib.groovy +++ b/grails-web-gsp-taglib/src/main/groovy/org/grails/plugins/web/taglib/RenderTagLib.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -73,10 +73,10 @@ class RenderTagLib implements TagLibrary { Encoder htmlEncoder = codecLookup.lookupEncoder('HTML') def currentOut = out - int statusCode = request.getAttribute('javax.servlet.error.status_code') as int + int statusCode = request.getAttribute('jakarta.servlet.error.status_code') as int currentOut << """

Error ${prettyPrintStatus(statusCode)}

-
URI
${htmlEncoder.encode(WebUtils.getForwardURI(request) ?: request.getAttribute('javax.servlet.error.request_uri'))}
+
URI
${htmlEncoder.encode(WebUtils.getForwardURI(request) ?: request.getAttribute('jakarta.servlet.error.request_uri'))}
""" def root = ExceptionUtils.getRootCause(exception) diff --git a/grails-web-gsp/build.gradle b/grails-web-gsp/build.gradle index 62aa89c918..62668e81a9 100644 --- a/grails-web-gsp/build.gradle +++ b/grails-web-gsp/build.gradle @@ -1,10 +1,10 @@ dependencies { compileOnly "org.apache.ant:ant:${antVersion}" - api "javax.servlet:javax.servlet-api:$servletApiVersion" + api "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" api project(":grails-gsp") api "org.grails:grails-web-common:$grailsVersion" api project(":grails-web-taglib") - api "org.sitemesh:grails-plugin-sitemesh3:6.2.0" + testImplementation "net.bytebuddy:byte-buddy:$byteBuddyVersion" testRuntimeOnly "org.grails:grails-spring:$grailsVersion" } diff --git a/grails-web-gsp/src/main/groovy/grails/gsp/PageRenderer.groovy b/grails-web-gsp/src/main/groovy/grails/gsp/PageRenderer.groovy index 53d437e76c..ee803ba942 100644 --- a/grails-web-gsp/src/main/groovy/grails/gsp/PageRenderer.groovy +++ b/grails-web-gsp/src/main/groovy/grails/gsp/PageRenderer.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2011 SpringSource + * Copyright 2011-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,6 +14,7 @@ * limitations under the License. */ package grails.gsp + import org.grails.buffer.FastStringWriter import org.grails.gsp.GroovyPagesTemplateEngine import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator @@ -24,14 +25,15 @@ import org.springframework.context.ApplicationContextAware import org.springframework.web.context.ServletContextAware import org.springframework.web.context.request.RequestContextHolder -import javax.servlet.ServletContext -import javax.servlet.http.Cookie -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.ServletContext +import jakarta.servlet.http.Cookie +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import java.lang.reflect.InvocationHandler import java.lang.reflect.Method import java.lang.reflect.Proxy import java.util.concurrent.ConcurrentHashMap + /** * Simplified API for rendering GSP pages from services, jobs and other non-request classes. * diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java b/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java index 6c48adb92a..78cc6b4b08 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocator.java @@ -1,11 +1,11 @@ /* - * Copyright 2011 SpringSource + * Copyright 2011-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,13 +16,13 @@ package org.grails.web.gsp.io; import grails.core.GrailsApplication; -import grails.core.GrailsClass; import grails.core.GrailsControllerClass; import grails.core.support.GrailsApplicationAware; import grails.util.GrailsNameUtils; import grails.web.mime.MimeType; import grails.web.mime.MimeTypeResolver; import grails.web.pages.GroovyPagesUriService; +import jakarta.servlet.http.HttpServletRequest; import org.grails.core.artefact.ControllerArtefactHandler; import org.grails.gsp.io.DefaultGroovyPageLocator; import org.grails.gsp.io.GroovyPageScriptSource; @@ -33,8 +33,6 @@ import org.grails.web.util.GrailsApplicationAttributes; import org.springframework.beans.factory.annotation.Autowired; -import javax.servlet.http.HttpServletRequest; - /** * Extended GroovyPageLocator that deals with the details of Grails' conventions * for controllers names, view names and template names diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/pages/GSPResponseWriter.java b/grails-web-gsp/src/main/groovy/org/grails/web/pages/GSPResponseWriter.java index aaafe41b79..a9e00bf88d 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/pages/GSPResponseWriter.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/pages/GSPResponseWriter.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -30,7 +30,7 @@ import org.springframework.objenesis.ObjenesisStd; import org.springframework.objenesis.instantiator.ObjectInstantiator; -import javax.servlet.ServletResponse; +import jakarta.servlet.ServletResponse; import java.io.IOException; import java.io.Writer; diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/pages/GroovyPagesServlet.java b/grails-web-gsp/src/main/groovy/org/grails/web/pages/GroovyPagesServlet.java index fcf8c4ef3d..83fb7d6dfb 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/pages/GroovyPagesServlet.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/pages/GroovyPagesServlet.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +19,6 @@ import grails.plugins.GrailsPluginManager; import grails.plugins.PluginManagerAware; import grails.util.GrailsStringUtils; -import org.grails.web.sitemesh.GroovyPageLayoutFinder; import org.grails.web.util.GrailsApplicationAttributes; import groovy.text.Template; import org.grails.core.io.support.GrailsFactoriesLoader; @@ -38,10 +37,9 @@ import org.springframework.web.servlet.FrameworkServlet; import org.springframework.web.util.WebUtils; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletContext; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -76,6 +74,8 @@ public class GroovyPagesServlet extends FrameworkServlet implements PluginManage private static final long serialVersionUID = -1918149859392123495L; + public static final String RENDERING_VIEW_ATTRIBUTE = "org.grails.rendering.view"; + private static final String WEB_INF = "/WEB-INF"; private static final String GRAILS_APP = "/grails-app"; @@ -159,7 +159,7 @@ protected void doService(HttpServletRequest request, HttpServletResponse respons } protected String getCurrentRequestUri(HttpServletRequest request) { - Object includePath = request.getAttribute("javax.servlet.include.servlet_path"); + Object includePath = request.getAttribute("jakarta.servlet.include.servlet_path"); if (includePath != null) { return (String) includePath; } @@ -216,7 +216,7 @@ protected GroovyPageScriptSource findPageInBinaryPlugins(String pageName) { */ protected void renderPageWithEngine(GroovyPagesTemplateEngine engine, HttpServletRequest request, HttpServletResponse response, GroovyPageScriptSource scriptSource) throws Exception { - request.setAttribute(GroovyPageLayoutFinder.RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE); + request.setAttribute(RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE); GSPResponseWriter out = createResponseWriter(response); try { Template template = engine.createTemplate(scriptSource); diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageView.java b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageView.java index 3dc47ac3a1..083836cfdc 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageView.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageView.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -17,14 +17,13 @@ import grails.util.Environment; import grails.util.GrailsUtil; -import groovy.lang.Writable; import groovy.text.Template; import java.io.IOException; import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,10 +33,11 @@ import org.grails.gsp.GroovyPagesTemplateEngine; import org.grails.gsp.GroovyPagesException; import org.grails.web.servlet.mvc.GrailsWebRequest; -import org.grails.web.sitemesh.GroovyPageLayoutFinder; import org.springframework.core.io.Resource; import org.springframework.scripting.ScriptSource; +import static org.grails.web.pages.GroovyPagesServlet.RENDERING_VIEW_ATTRIBUTE; + /** * A Spring View that renders Groovy Server Pages to the response. It requires an instance * of GroovyPagesTemplateEngine to be set and will render to view returned by the getUrl() @@ -67,7 +67,7 @@ public class GroovyPageView extends AbstractGrailsView { @Override protected void renderTemplate(Map model, GrailsWebRequest webRequest, HttpServletRequest request, HttpServletResponse response) { - request.setAttribute(GroovyPageLayoutFinder.RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE); + request.setAttribute(RENDERING_VIEW_ATTRIBUTE, Boolean.TRUE); GSPResponseWriter out = null; try { out = createResponseWriter(webRequest, response); diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageViewResolver.java b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageViewResolver.java index 2a521da430..50c073907c 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageViewResolver.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageViewResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,18 +19,10 @@ import grails.util.GrailsStringUtils; import grails.util.GrailsUtil; import groovy.lang.GroovyObject; - -import java.util.Locale; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import javax.servlet.http.HttpServletRequest; - - +import jakarta.servlet.http.HttpServletRequest; import org.grails.gsp.GroovyPagesTemplateEngine; -import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator; import org.grails.gsp.io.GroovyPageScriptSource; +import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator; import org.grails.web.servlet.mvc.GrailsWebRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,6 +35,11 @@ import org.springframework.web.servlet.view.AbstractUrlBasedView; import org.springframework.web.servlet.view.InternalResourceViewResolver; +import java.util.Locale; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + /** * Evaluates the existance of a view for different extensions choosing which one to delegate to. * diff --git a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/NullView.java b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/NullView.java index 99ca4b4cf2..57295b52df 100644 --- a/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/NullView.java +++ b/grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/NullView.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,13 +15,12 @@ */ package org.grails.web.servlet.view; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.servlet.View; +import java.util.Map; + /** * A view that does nothing. * diff --git a/grails-web-gsp/src/test/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocatorSpec.groovy b/grails-web-gsp/src/test/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocatorSpec.groovy index e4e845bf3e..4d27b7b4b0 100644 --- a/grails-web-gsp/src/test/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocatorSpec.groovy +++ b/grails-web-gsp/src/test/groovy/org/grails/web/gsp/io/GrailsConventionGroovyPageLocatorSpec.groovy @@ -5,6 +5,7 @@ import grails.plugins.DefaultGrailsPluginManager import grails.plugins.metadata.GrailsPlugin import grails.util.GrailsUtil import grails.util.GrailsWebMockUtil +import groovy.xml.XmlSlurper import org.grails.core.io.SimpleMapResourceLoader import org.grails.gsp.compiler.GroovyPageParser import org.grails.gsp.io.GroovyPageCompiledScriptSource diff --git a/grails-web-gsp/src/test/groovy/org/grails/web/servlet/view/GroovyPageViewResolverSpec.groovy b/grails-web-gsp/src/test/groovy/org/grails/web/servlet/view/GroovyPageViewResolverSpec.groovy index eaaf430589..8734bf43ce 100644 --- a/grails-web-gsp/src/test/groovy/org/grails/web/servlet/view/GroovyPageViewResolverSpec.groovy +++ b/grails-web-gsp/src/test/groovy/org/grails/web/servlet/view/GroovyPageViewResolverSpec.groovy @@ -9,7 +9,7 @@ import org.springframework.web.servlet.View import org.springframework.web.servlet.view.InternalResourceView import spock.lang.Specification -import javax.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletRequest class GroovyPageViewResolverSpec extends Specification { def "should use namespace as part of cache key"() { diff --git a/grails-web-jsp/build.gradle b/grails-web-jsp/build.gradle index 3557fb8424..09a9af5ea1 100644 --- a/grails-web-jsp/build.gradle +++ b/grails-web-jsp/build.gradle @@ -2,8 +2,10 @@ dependencies { api "org.grails:grails-web-common:$grailsVersion" api project(":grails-web-gsp") - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" + + compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" // Required for JSP support - compileOnly "javax.servlet.jsp:jsp-api:${jspApiVersion}" + compileOnly "jakarta.servlet.jsp:jakarta.servlet.jsp-api:$jspApiVersion" + compileOnly "jakarta.el:jakarta.el-api:$elApiVersion" } diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/BodyContentImpl.java b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/BodyContentImpl.java index f8556b7c08..99e1a2ef76 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/BodyContentImpl.java +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/BodyContentImpl.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,15 +15,14 @@ */ package org.grails.gsp.jsp; +import jakarta.servlet.jsp.JspWriter; +import jakarta.servlet.jsp.tagext.BodyContent; +import org.grails.buffer.StreamCharBuffer; + import java.io.IOException; import java.io.Reader; import java.io.Writer; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.tagext.BodyContent; - -import org.grails.buffer.StreamCharBuffer; - /** * Uses an internal CharArrayWriter. * diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspApplicationContext.java b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspApplicationContext.java index 6b341e22d3..616eebd62b 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspApplicationContext.java +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspApplicationContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,14 +15,14 @@ */ package org.grails.gsp.jsp; +import jakarta.el.*; +import jakarta.servlet.jsp.JspApplicationContext; +import jakarta.servlet.jsp.el.ImplicitObjectELResolver; +import jakarta.servlet.jsp.el.ScopedAttributeELResolver; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.util.ClassUtils; -import javax.el.*; -import javax.servlet.jsp.JspApplicationContext; -import javax.servlet.jsp.el.ImplicitObjectELResolver; -import javax.servlet.jsp.el.ScopedAttributeELResolver; import java.util.Iterator; import java.util.LinkedList; diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspFactory.groovy b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspFactory.groovy index e98e3b5ce3..6cbbe92b50 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspFactory.groovy +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesJspFactory.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,14 +15,14 @@ */ package org.grails.gsp.jsp -import javax.servlet.Servlet -import javax.servlet.ServletContext -import javax.servlet.ServletRequest -import javax.servlet.ServletResponse -import javax.servlet.jsp.JspApplicationContext -import javax.servlet.jsp.JspEngineInfo -import javax.servlet.jsp.JspFactory -import javax.servlet.jsp.PageContext +import jakarta.servlet.Servlet +import jakarta.servlet.ServletContext +import jakarta.servlet.ServletRequest +import jakarta.servlet.ServletResponse +import jakarta.servlet.jsp.JspApplicationContext +import jakarta.servlet.jsp.JspEngineInfo +import jakarta.servlet.jsp.JspFactory +import jakarta.servlet.jsp.PageContext /** * @author Graeme Rocher diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesPageContext.java b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesPageContext.java index b76cbba295..604eff1ff2 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesPageContext.java +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/GroovyPagesPageContext.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,35 +16,22 @@ package org.grails.gsp.jsp; import groovy.lang.Binding; - -import java.io.IOException; -import java.io.Writer; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.*; - -import javax.el.ELContext; -import javax.servlet.GenericServlet; -import javax.servlet.Servlet; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.jsp.*; -import javax.servlet.jsp.el.ELException; -import javax.servlet.jsp.el.ExpressionEvaluator; -import javax.servlet.jsp.el.VariableResolver; -import javax.servlet.jsp.tagext.BodyContent; - +import jakarta.el.ELContext; +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import jakarta.servlet.jsp.*; +import jakarta.servlet.jsp.tagext.BodyContent; import org.grails.gsp.GroovyPage; import org.grails.web.servlet.mvc.GrailsWebRequest; import org.springframework.util.Assert; import org.springframework.web.context.request.RequestContextHolder; +import java.io.IOException; +import java.io.Writer; +import java.util.*; + /** * A JSP PageContext implementation for use with GSP. * @@ -53,29 +40,27 @@ */ public class GroovyPagesPageContext extends PageContext { - private static final Enumeration EMPTY_ENUMERATION = new Enumeration() { + private static final Enumeration EMPTY_ENUMERATION = new Enumeration<>() { @Override public boolean hasMoreElements() { return false; } @Override - public Object nextElement() { - return new NoSuchElementException(); + public String nextElement() { + throw new NoSuchElementException(); } }; - private ServletContext servletContext; - private Servlet servlet; - private HttpServletRequest request; - private HttpServletResponse response; - private ServletConfig servletconfig; - private Binding pageScope; - private GrailsWebRequest webRequest; + private final ServletContext servletContext; + private final Servlet servlet; + private final HttpServletRequest request; + private final HttpServletResponse response; + private final ServletConfig servletConfig; + private final Binding pageScope; + private final GrailsWebRequest webRequest; private JspWriter jspOut; - private Deque outStack = new ArrayDeque(); - @SuppressWarnings("rawtypes") - private List tags = new ArrayList(); - private HttpSession session; + private final Deque outStack = new ArrayDeque<>(); + private final List tags = new ArrayList<>(); public GroovyPagesPageContext(Servlet pagesServlet, Binding pageScope) { Assert.notNull(pagesServlet, "GroovyPagesPageContext class requires a reference to the GSP servlet"); @@ -85,9 +70,9 @@ public GroovyPagesPageContext(Servlet pagesServlet, Binding pageScope) { request = webRequest.getCurrentRequest(); response = webRequest.getCurrentResponse(); servlet = pagesServlet; - servletconfig = pagesServlet.getServletConfig(); + servletConfig = pagesServlet.getServletConfig(); this.pageScope = pageScope; - session = request.getSession(false); + var session = request.getSession(false); // setup initial writer pushWriter(new JspWriterDelegate(webRequest.getOut())); // Register page attributes as per JSP spec @@ -134,7 +119,6 @@ void popTopTag() { tags.remove(tags.size() - 1); } - @SuppressWarnings("unchecked") void pushTopTag(Object tag) { tags.add(tag); } @@ -152,7 +136,6 @@ public JspWriter popBody() { return (JspWriter) getAttribute(OUT); } - @SuppressWarnings("serial") public GroovyPagesPageContext(Binding pageScope) { this(new GenericServlet() { @Override @@ -160,7 +143,7 @@ public ServletConfig getServletConfig() { return this; } @Override - public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { + public void service(ServletRequest servletRequest, ServletResponse servletResponse) { // do nothing; } }, pageScope != null ? pageScope : new Binding()); @@ -208,7 +191,7 @@ public Exception getException() { @Override public ServletConfig getServletConfig() { - return servletconfig; + return servletConfig; } @Override @@ -360,27 +343,26 @@ public int getAttributesScope(String name) { return 0; } - @SuppressWarnings("rawtypes") @Override - public Enumeration getAttributeNamesInScope(int scope) { + public Enumeration getAttributeNamesInScope(int scope) { switch (scope) { case PAGE_SCOPE: - final Iterator i = pageScope.getVariables().keySet().iterator(); - return new Enumeration() { + final var i = ((Map) pageScope.getVariables()).keySet().iterator(); + return new Enumeration<>() { @Override public boolean hasMoreElements() { return i.hasNext(); } @Override - public Object nextElement() { + public String nextElement() { return i.next(); } }; case REQUEST_SCOPE: return request.getAttributeNames(); case SESSION_SCOPE: - HttpSession httpSession = request.getSession(false); + var httpSession = request.getSession(false); if (httpSession != null) { return httpSession.getAttributeNames(); } @@ -405,32 +387,27 @@ public JspWriter getOut() { return (JspWriter)out; } - @Override - public ExpressionEvaluator getExpressionEvaluator() { - try { - Class type = AccessController.doPrivileged(new PrivilegedAction() { - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - }).loadClass("org.apache.commons.el.ExpressionEvaluatorImpl"); - return (ExpressionEvaluator) type.newInstance(); - } - catch (Exception e) { - throw new UnsupportedOperationException("In order for the getExpressionEvaluator() " + - "method to work, you must have downloaded the apache commons-el jar and " + - "made it available in the classpath."); - } - } - - @Override - public VariableResolver getVariableResolver() { - final PageContext ctx = this; - return new VariableResolver() { - public Object resolveVariable(String name) throws ELException { - return ctx.findAttribute(name); - } - }; - } +// public ExpressionFactory getExpressionEvaluator() { +// try { +// Class type = AccessController.doPrivileged((PrivilegedAction) () -> Thread.currentThread().getContextClassLoader()).loadClass("jakarta.el.ExpressionFactory"); +// return (ExpressionFactory) type.getDeclaredConstructor().newInstance(); +// } +// catch (Exception e) { +// throw new UnsupportedOperationException("In order for the getExpressionEvaluator() " + +// "method to work, you must have downloaded the apache commons-el jar and " + +// "made it available in the classpath."); +// } +// } + +// @Override +// public VariableResolver getVariableResolver() { +// final PageContext ctx = this; +// return new VariableResolver() { +// public Object resolveVariable(String name) throws ELException { +// return ctx.findAttribute(name); +// } +// }; +// } static { if (JspFactory.getDefaultFactory() == null) { @@ -440,6 +417,7 @@ public Object resolveVariable(String name) throws ELException { private ELContext elContext; + @Override public ELContext getELContext() { if (elContext == null) { JspApplicationContext jspContext = JspFactory.getDefaultFactory().getJspApplicationContext(getServletContext()); diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspTagImpl.groovy b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspTagImpl.groovy index 9ae020742d..f55f20df4e 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspTagImpl.groovy +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspTagImpl.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -22,9 +22,9 @@ import org.grails.buffer.FastStringWriter import org.springframework.beans.BeanWrapperImpl import org.springframework.util.ClassUtils -import javax.servlet.jsp.JspContext -import javax.servlet.jsp.JspWriter -import javax.servlet.jsp.tagext.* +import jakarta.servlet.jsp.JspContext +import jakarta.servlet.jsp.JspWriter +import jakarta.servlet.jsp.tagext.* /** * @author Graeme Rocher @@ -71,13 +71,13 @@ class JspTagImpl implements JspTag { iteration = IterationTag.isAssignableFrom(tagClass) } - protected javax.servlet.jsp.tagext.JspTag createTagInstance() { + protected jakarta.servlet.jsp.tagext.JspTag createTagInstance() { checkInitialized() - (javax.servlet.jsp.tagext.JspTag)tagClass.newInstance() + (jakarta.servlet.jsp.tagext.JspTag)tagClass.newInstance() } void doTag(Writer targetWriter, Map attributes, Closure body) { - javax.servlet.jsp.tagext.JspTag tag = createTagInstance() + jakarta.servlet.jsp.tagext.JspTag tag = createTagInstance() GroovyPagesPageContext pageContext = PageContextFactory.getCurrent() assignParentTag(pageContext, tag) @@ -143,7 +143,7 @@ class JspTagImpl implements JspTag { } } - private assignPageContext(GroovyPagesPageContext pageContext, javax.servlet.jsp.tagext.JspTag tag) { + private assignPageContext(GroovyPagesPageContext pageContext, jakarta.servlet.jsp.tagext.JspTag tag) { if (tag instanceof SimpleTag) { tag.jspContext = pageContext } @@ -152,7 +152,7 @@ class JspTagImpl implements JspTag { } } - private applyAttributes(javax.servlet.jsp.tagext.JspTag tag, Map attributes) { + private applyAttributes(jakarta.servlet.jsp.tagext.JspTag tag, Map attributes) { BeanWrapperImpl tagBean = new BeanWrapperImpl(tag) attributes?.each { String key, Object value -> @@ -165,8 +165,8 @@ class JspTagImpl implements JspTag { } } - private assignParentTag(GroovyPagesPageContext pageContext, javax.servlet.jsp.tagext.JspTag tag) { - def parentTag = pageContext.peekTopTag(javax.servlet.jsp.tagext.JspTag) + private assignParentTag(GroovyPagesPageContext pageContext, jakarta.servlet.jsp.tagext.JspTag tag) { + def parentTag = pageContext.peekTopTag(jakarta.servlet.jsp.tagext.JspTag) if (parentTag) { if (tag instanceof Tag && parentTag instanceof SimpleTag) { tag.parent = new TagAdapter(parentTag) diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspWriterDelegate.java b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspWriterDelegate.java index 41b94eaee2..0c8e1807fd 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspWriterDelegate.java +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/JspWriterDelegate.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,11 +15,11 @@ */ package org.grails.gsp.jsp; +import jakarta.servlet.jsp.JspWriter; + import java.io.IOException; import java.io.Writer; -import javax.servlet.jsp.JspWriter; - /** * Delegates to another java.io.Writer. * diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/LocalEntityResolver.java b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/LocalEntityResolver.java index 73dc7e6ce9..09df10b25b 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/LocalEntityResolver.java +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/LocalEntityResolver.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,16 +15,14 @@ */ package org.grails.gsp.jsp; -import grails.util.CollectionUtils; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.Map; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; +import static java.util.Map.entry; /** * Resolves commons JSP DTDs and Schema definitions locally. @@ -33,30 +31,42 @@ */ public class LocalEntityResolver implements EntityResolver { - @SuppressWarnings("unchecked") - private static final Map ENTITIES = CollectionUtils.newMap( + private static final Map ENTITIES = Map.ofEntries( + // JSP taglib 3.0 + entry("https://jakarta.ee/xml/ns/jakartaee/web-jsptaglibrary_3_0.xsd", "web-jsptaglibrary_3_0.xsd"), // JSP taglib 2.1 - "http://java.sun.com/xml/ns/jee/web-jsptaglibrary_2_1.xsd", "web-jsptaglibrary_2_1.xsd", + entry("http://java.sun.com/xml/ns/jee/web-jsptaglibrary_2_1.xsd", "web-jsptaglibrary_2_1.xsd"), // JSP taglib 2.0 - "http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd", "web-jsptaglibrary_2_0.xsd", + entry("http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd", "web-jsptaglibrary_2_0.xsd"), // JSP taglib 1.2 - "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN", "web-jsptaglibrary_1_2.dtd", - "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd", "web-jsptaglibrary_1_2.dtd", + entry("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN", "web-jsptaglibrary_1_2.dtd"), + entry("http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd", "web-jsptaglibrary_1_2.dtd"), // JSP taglib 1.1 - "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN", "web-jsptaglibrary_1_1.dtd", - "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd", "web-jsptaglibrary_1_1.dtd", + entry("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN", "web-jsptaglibrary_1_1.dtd"), + entry("http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd", "web-jsptaglibrary_1_1.dtd"), + // Servlet 6.0 + entry("https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd", "web-app_6_0.xsd"), + // Servlet 5.0 + entry("https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd", "web-app_5_0.xsd"), + // Servlet 4.0 + entry("http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd", "web-app_4_0.xsd"), + // Servlet 3.1 + entry("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd", "web-app_3_1.xsd"), + // Servlet 3.0 + entry("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd", "web-app_3_0.xsd"), // Servlet 2.5 - "http://java.sun.com/xml/ns/jee/web-app_2_5.xsd", "web-app_2_5.xsd", + entry("http://java.sun.com/xml/ns/jee/web-app_2_5.xsd", "web-app_2_5.xsd"), // Servlet 2.4 - "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", "web-app_2_4.xsd", + entry("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", "web-app_2_4.xsd"), // Servlet 2.3 - "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", "web-app_2_3.dtd", - "http://java.sun.com/dtd/web-app_2_3.dtd", "web-app_2_3.dtd", + entry("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", "web-app_2_3.dtd"), + entry("http://java.sun.com/dtd/web-app_2_3.dtd", "web-app_2_3.dtd"), // Servlet 2.2 - "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", "web-app_2_2.dtd", - "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd", "web-app_2_2.dtd"); + entry("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", "web-app_2_2.dtd"), + entry("http://java.sun.com/j2ee/dtds/web-app_2_2.dtd", "web-app_2_2.dtd") + ); - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { + public InputSource resolveEntity(String publicId, String systemId) { String name = ENTITIES.get(publicId); if (name == null) name = ENTITIES.get(systemId); diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/PageContextFactory.groovy b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/PageContextFactory.groovy index e1774701d1..e43ec81d12 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/PageContextFactory.groovy +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/PageContextFactory.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 Graeme Rocher + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,8 +21,8 @@ import org.grails.web.servlet.mvc.GrailsWebRequest import org.grails.web.util.GrailsApplicationAttributes as GAA import org.springframework.web.context.request.RequestContextHolder -import javax.servlet.ServletContext -import javax.servlet.jsp.PageContext as PC +import jakarta.servlet.ServletContext +import jakarta.servlet.jsp.PageContext as PC /** * Obtains a reference to the GroovyPagesPageContext class. diff --git a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolverImpl.groovy b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolverImpl.groovy index 826caa50a0..ead343a8ed 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolverImpl.groovy +++ b/grails-web-jsp/src/main/groovy/org/grails/gsp/jsp/TagLibraryResolverImpl.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap import java.util.zip.ZipEntry import java.util.zip.ZipInputStream -import javax.servlet.ServletContext +import jakarta.servlet.ServletContext import grails.core.GrailsApplication import grails.core.support.GrailsApplicationAware diff --git a/grails-web-jsp/src/main/groovy/org/grails/web/taglib/jsp/JspInvokeGrailsTagLibTag.java b/grails-web-jsp/src/main/groovy/org/grails/web/taglib/jsp/JspInvokeGrailsTagLibTag.java index 5c00ff01f0..8fc56fdc3c 100644 --- a/grails-web-jsp/src/main/groovy/org/grails/web/taglib/jsp/JspInvokeGrailsTagLibTag.java +++ b/grails-web-jsp/src/main/groovy/org/grails/web/taglib/jsp/JspInvokeGrailsTagLibTag.java @@ -1,11 +1,11 @@ /* - * Copyright 2004-2005 the original author or authors. + * Copyright 2004-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -31,12 +31,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.tagext.BodyContent; -import javax.servlet.jsp.tagext.BodyTagSupport; -import javax.servlet.jsp.tagext.DynamicAttributes; +import jakarta.servlet.jsp.JspException; +import jakarta.servlet.jsp.JspTagException; +import jakarta.servlet.jsp.JspWriter; +import jakarta.servlet.jsp.tagext.BodyContent; +import jakarta.servlet.jsp.tagext.BodyTagSupport; +import jakarta.servlet.jsp.tagext.DynamicAttributes; import grails.core.GrailsApplication; import org.grails.core.artefact.TagLibArtefactHandler; diff --git a/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_4_0.xsd b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_4_0.xsd new file mode 100644 index 0000000000..8619ef6f32 --- /dev/null +++ b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_4_0.xsd @@ -0,0 +1,365 @@ + + + + + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + + Copyright (c) 2009-2017 Oracle and/or its affiliates. All rights reserved. + + The contents of this file are subject to the terms of either the GNU + General Public License Version 2 only ("GPL") or the Common Development + and Distribution License("CDDL") (collectively, the "License"). You + may not use this file except in compliance with the License. You can + obtain a copy of the License at + https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + or packager/legal/LICENSE.txt. See the License for the specific + language governing permissions and limitations under the License. + + When distributing the software, include this License Header Notice in each + file and include the License file at packager/legal/LICENSE.txt. + + GPL Classpath Exception: + Oracle designates this particular file as subject to the "Classpath" + exception as provided by Oracle in the GPL Version 2 section of the License + file that accompanied this code. + + Modifications: + If applicable, add the following below the License Header, with the fields + enclosed by brackets [] replaced by your own identifying information: + "Portions Copyright [year] [name of copyright owner]" + + Contributor(s): + If you wish your version of this file to be governed by only the CDDL or + only the GPL Version 2, indicate your decision by adding "[Contributor] + elects to include this software in this distribution under the [CDDL or GPL + Version 2] license." If you don't indicate a single choice of license, a + recipient has the option to distribute your version of this file under + either the CDDL, the GPL Version 2 or to extend the choice of license to + its licensees as provided above. However, if you add GPL Version 2 code + and therefore, elected the GPL Version 2 license, then the option applies + only if the new code is made subject to such option by the copyright + holder. + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for Java EE + namespace with the following location: + + http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd + + ]]> + + + + + + + The following conventions apply to all Java EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + The web-app element is the root of the deployment + descriptor for a web application. Note that the sub-elements + of this element can be in the arbitrary order. Because of + that, the multiplicity of the elements of distributable, + session-config, welcome-file-list, jsp-config, login-config, + and locale-encoding-mapping-list was changed from "?" to "*" + in this schema. However, the deployment descriptor instance + file must not contain multiple elements of session-config, + jsp-config, and login-config. When there are multiple elements of + welcome-file-list or locale-encoding-mapping-list, the container + must concatenate the element contents. The multiple occurence + of the element distributable is redundant and the container + treats that case exactly in the same way when there is only + one distributable. + + + + + + + + The servlet element contains the name of a servlet. + The name must be unique within the web application. + + + + + + + + + + + The filter element contains the name of a filter. + The name must be unique within the web application. + + + + + + + + + + + The ejb-local-ref-name element contains the name of an EJB + reference. The EJB reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The ejb-ref-name element contains the name of an EJB + reference. The EJB reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The resource-env-ref-name element specifies the name of + a resource environment reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The message-destination-ref-name element specifies the name of + a message destination reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. The name + is a JNDI name relative to the java:comp/env context. + The name must be unique within a web application. + + + + + + + + + + + The env-entry-name element contains the name of a web + application's environment entry. The name is a JNDI + name relative to the java:comp/env context. The name + must be unique within a web application. + + + + + + + + + + + A role-name-key is specified to allow the references + from the security-role-refs. + + + + + + + + + + + The keyref indicates the references from + security-role-ref to a specified role-name. + + + + + + + + + + + + + + + + + + + + When specified, this element provides a default context path + of the web application. An empty value for this element must cause + the web application to be deployed at the root for the container. + Otherwise, the default context path must start with + a “/“ character but not end with a “/“ character. + Servlet containers may provide vendor specific configuration + options that allows specifying a value that overrides the value + specified here. + + + + + + + + + When specified, this element provides a default request + character encoding of the web application. + + + + + + + + + When specified, this element provides a default response + character encoding of the web application. + + + + + + + + + When specified, this element causes uncovered http methods + to be denied. For every url-pattern that is the target of a + security-constrant, this element causes all HTTP methods that + are NOT covered (by a security constraint) at the url-pattern + to be denied. + + + + + + + + + + + + + + + + + Please see section 8.2.2 of the specification for details. + + + + + + + + + + diff --git a/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_5_0.xsd b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_5_0.xsd new file mode 100644 index 0000000000..55d11dbdc4 --- /dev/null +++ b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_5_0.xsd @@ -0,0 +1,342 @@ + + + + + + Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for Jakarta EE + namespace with the following location: + + https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd + + ]]> + + + + + + + The following conventions apply to all Jakarta EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + The web-app element is the root of the deployment + descriptor for a web application. Note that the sub-elements + of this element can be in the arbitrary order. Because of + that, the multiplicity of the elements of distributable, + session-config, welcome-file-list, jsp-config, login-config, + and locale-encoding-mapping-list was changed from "?" to "*" + in this schema. However, the deployment descriptor instance + file must not contain multiple elements of session-config, + jsp-config, and login-config. When there are multiple elements of + welcome-file-list or locale-encoding-mapping-list, the container + must concatenate the element contents. The multiple occurence + of the element distributable is redundant and the container + treats that case exactly in the same way when there is only + one distributable. + + + + + + + + The servlet element contains the name of a servlet. + The name must be unique within the web application. + + + + + + + + + + + The filter element contains the name of a filter. + The name must be unique within the web application. + + + + + + + + + + + The ejb-local-ref-name element contains the name of an + enterprise bean reference. The enterprise + bean reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The ejb-ref-name element contains the name of an + enterprise bean reference. The enterprise bean + reference is an entry in the web application's environment + and is relative to the java:comp/env context. + The name must be unique within the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The resource-env-ref-name element specifies the name of + a resource environment reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The message-destination-ref-name element specifies the name of + a message destination reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. The name + is a JNDI name relative to the java:comp/env context. + The name must be unique within a web application. + + + + + + + + + + + The env-entry-name element contains the name of a web + application's environment entry. The name is a JNDI + name relative to the java:comp/env context. The name + must be unique within a web application. + + + + + + + + + + + A role-name-key is specified to allow the references + from the security-role-refs. + + + + + + + + + + + The keyref indicates the references from + security-role-ref to a specified role-name. + + + + + + + + + + + + + + + + + + + + When specified, this element provides a default context path + of the web application. An empty value for this element must cause + the web application to be deployed at the root for the container. + Otherwise, the default context path must start with + a "/" character but not end with a "/" character. + Servlet containers may provide vendor specific configuration + options that allows specifying a value that overrides the value + specified here. + + + + + + + + + When specified, this element provides a default request + character encoding of the web application. + + + + + + + + + When specified, this element provides a default response + character encoding of the web application. + + + + + + + + + When specified, this element causes uncovered http methods + to be denied. For every url-pattern that is the target of a + security-constrant, this element causes all HTTP methods that + are NOT covered (by a security constraint) at the url-pattern + to be denied. + + + + + + + + + + + + + + + + + Please see section 8.2.2 of the specification for details. + + + + + + + + + + diff --git a/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_6_0.xsd b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_6_0.xsd new file mode 100644 index 0000000000..a268373908 --- /dev/null +++ b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-app_6_0.xsd @@ -0,0 +1,342 @@ + + + + + + Copyright (c) 2009, 2021 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + + ... + + + The instance documents may indicate the published version of + the schema using the xsi:schemaLocation attribute for Jakarta EE + namespace with the following location: + + https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd + + ]]> + + + + + + + The following conventions apply to all Jakarta EE + deployment descriptor elements unless indicated otherwise. + + - In elements that specify a pathname to a file within the + same JAR file, relative filenames (i.e., those not + starting with "/") are considered relative to the root of + the JAR file's namespace. Absolute filenames (i.e., those + starting with "/") also specify names in the root of the + JAR file's namespace. In general, relative names are + preferred. The exception is .war files where absolute + names are preferred for consistency with the Servlet API. + + + + + + + + + + + + + + The web-app element is the root of the deployment + descriptor for a web application. Note that the sub-elements + of this element can be in the arbitrary order. Because of + that, the multiplicity of the elements of distributable, + session-config, welcome-file-list, jsp-config, login-config, + and locale-encoding-mapping-list was changed from "?" to "*" + in this schema. However, the deployment descriptor instance + file must not contain multiple elements of session-config, + jsp-config, and login-config. When there are multiple elements of + welcome-file-list or locale-encoding-mapping-list, the container + must concatenate the element contents. The multiple occurence + of the element distributable is redundant and the container + treats that case exactly in the same way when there is only + one distributable. + + + + + + + + The servlet element contains the name of a servlet. + The name must be unique within the web application. + + + + + + + + + + + The filter element contains the name of a filter. + The name must be unique within the web application. + + + + + + + + + + + The ejb-local-ref-name element contains the name of an + enterprise bean reference. The enterprise + bean reference is an entry in the web + application's environment and is relative to the + java:comp/env context. The name must be unique within + the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The ejb-ref-name element contains the name of an + enterprise bean reference. The enterprise bean + reference is an entry in the web application's environment + and is relative to the java:comp/env context. + The name must be unique within the web application. + + It is recommended that name is prefixed with "ejb/". + + + + + + + + + + + The resource-env-ref-name element specifies the name of + a resource environment reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The message-destination-ref-name element specifies the name of + a message destination reference; its value is the + environment entry name used in the web application code. + The name is a JNDI name relative to the java:comp/env + context and must be unique within a web application. + + + + + + + + + + + The res-ref-name element specifies the name of a + resource manager connection factory reference. The name + is a JNDI name relative to the java:comp/env context. + The name must be unique within a web application. + + + + + + + + + + + The env-entry-name element contains the name of a web + application's environment entry. The name is a JNDI + name relative to the java:comp/env context. The name + must be unique within a web application. + + + + + + + + + + + A role-name-key is specified to allow the references + from the security-role-refs. + + + + + + + + + + + The keyref indicates the references from + security-role-ref to a specified role-name. + + + + + + + + + + + + + + + + + + + + When specified, this element provides a default context path + of the web application. An empty value for this element must cause + the web application to be deployed at the root for the container. + Otherwise, the default context path must start with + a "/" character but not end with a "/" character. + Servlet containers may provide vendor specific configuration + options that allows specifying a value that overrides the value + specified here. + + + + + + + + + When specified, this element provides a default request + character encoding of the web application. + + + + + + + + + When specified, this element provides a default response + character encoding of the web application. + + + + + + + + + When specified, this element causes uncovered http methods + to be denied. For every url-pattern that is the target of a + security-constrant, this element causes all HTTP methods that + are NOT covered (by a security constraint) at the url-pattern + to be denied. + + + + + + + + + + + + + + + + + Please see section 8.2.2 of the specification for details. + + + + + + + + + + diff --git a/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-jsptaglibrary_3_0.xsd b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-jsptaglibrary_3_0.xsd new file mode 100644 index 0000000000..a6b581fbf9 --- /dev/null +++ b/grails-web-jsp/src/main/resources/org/grails/gsp/jsp/web-jsptaglibrary_3_0.xsd @@ -0,0 +1,1109 @@ + + + + + + Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + + + + + + + ... + + + The instance documents may indicate the published + version of the schema using xsi:schemaLocation attribute + for Jakarta EE namespace with the following location: + + https://jakarta.ee/xml/ns/jakartaee/web-jsptaglibrary_3_0.xsd + + ]]> + + + + + + + + + + + + + The taglib tag is the document root. + The definition of taglib is provided + by the tldTaglibType. + + + + + + + + The taglib element contains, among other things, tag and + tag-file elements. + The name subelements of these elements must each be unique. + + + + + + + + + + + The taglib element contains function elements. + The name subelements of these elements must each be unique. + + + + + + + + + + + + + + + + Specifies the type of body that is valid for a tag. + This value is used by the JSP container to validate + that a tag invocation has the correct body syntax and + by page composition tools to assist the page author + in providing a valid tag body. + + There are currently four values specified: + + tagdependent The body of the tag is interpreted by the tag + implementation itself, and is most likely + in a different "language", e.g embedded SQL + statements. + + JSP The body of the tag contains nested JSP + syntax. + + empty The body must be empty + + scriptless The body accepts only template text, EL + Expressions, and JSP action elements. No + scripting elements are allowed. + + + + + + + + + + + + + + + + + + + + + Defines the canonical name of a tag or attribute being + defined. + + The name must conform to the lexical rules for an NMTOKEN. + + + + + + + + + + + + + + + + A validator that can be used to validate + the conformance of a JSP page to using this tag library is + defined by a validatorType. + + + + + + + + + + Defines the TagLibraryValidator class that can be used + to validate the conformance of a JSP page to using this + tag library. + + + + + + + + + The init-param element contains a name/value pair as an + initialization param. + + + + + + + + + + + + + + + + The tag defines a unique tag in this tag library. It has one + attribute, id. + + The tag element may have several subelements defining: + + description Optional tag-specific information + + display-name A short name that is intended to be + displayed by tools + + icon Optional icon element that can be used + by tools + + name The unique action name + + tag-class The tag handler class implementing + jakarta.servlet.jsp.tagext.JspTag + + tei-class An optional subclass of + jakarta.servlet.jsp.tagext.TagExtraInfo + + body-content The body content type + + variable Optional scripting variable information + + attribute All attributes of this action that are + evaluated prior to invocation. + + dynamic-attributes Whether this tag supports additional + attributes with dynamic names. If + true, the tag-class must implement the + jakarta.servlet.jsp.tagext.DynamicAttributes + interface. Defaults to false. + + example Optional informal description of an + example of a use of this tag + + tag-extension Zero or more extensions that provide extra + information about this tag, for tool + consumption + + + + + + + + + + + Defines the subclass of jakarta.serlvet.jsp.tagext.JspTag + that implements the request time semantics for + this tag. (required) + + + + + + + + + Defines the subclass of jakarta.servlet.jsp.tagext.TagExtraInfo + for this tag. (optional) + + If this is not given, the class is not consulted at + translation time. + + + + + + + + + Specifies the format for the body of this tag. + The default in JSP 1.2 was "JSP" but because this + is an invalid setting for simple tag handlers, there + is no longer a default in JSP 2.0. A reasonable + default for simple tag handlers is "scriptless" if + the tag can have a body. + + + + + + + + + + + + The example element contains an informal description + of an example of the use of a tag. + + + + + + + + + Tag extensions are for tool use only and must not affect + the behavior of a container. + + + + + + + + + + + + + + + + Defines an action in this tag library that is implemented + as a .tag file. + + The tag-file element has two required subelements: + + description Optional tag-specific information + + display-name A short name that is intended to be + displayed by tools + + icon Optional icon element that can be used + by tools + + name The unique action name + + path Where to find the .tag file implementing this + action, relative to the root of the web + application or the root of the JAR file for a + tag library packaged in a JAR. This must + begin with /WEB-INF/tags if the .tag file + resides in the WAR, or /META-INF/tags if the + .tag file resides in a JAR. + + example Optional informal description of an + example of a use of this tag + + tag-extension Zero or more extensions that provide extra + information about this tag, for tool + consumption + + + + + + + + + + + + The example element contains an informal description + of an example of the use of a tag. + + + + + + + + + Tag extensions are for tool use only and must not affect + the behavior of a container. + + + + + + + + + + + + + + + + The function element is used to provide information on each + function in the tag library that is to be exposed to the EL. + + The function element may have several subelements defining: + + description Optional tag-specific information + + display-name A short name that is intended to be + displayed by tools + + icon Optional icon element that can be used + by tools + + name A unique name for this function + + function-class Provides the name of the Java class that + implements the function + + function-signature Provides the signature, as in the Java + Language Specification, of the Java + method that is to be used to implement + the function. + + example Optional informal description of an + example of a use of this function + + function-extension Zero or more extensions that provide extra + information about this function, for tool + consumption + + + + + + + + + + A unique name for this function. + + + + + + + + + Provides the fully-qualified class name of the Java + class containing the static method that implements + the function. + + + + + + + + + Provides the signature, of the static Java method that is + to be used to implement the function. The syntax of the + function-signature element is as follows: + + FunctionSignature ::= ReturnType S MethodName S? + '(' S? Parameters? S? ')' + + ReturnType ::= Type + + MethodName ::= Identifier + + Parameters ::= Parameter + | ( Parameter S? ',' S? Parameters ) + + Parameter ::= Type + + Where: + + * Type is a basic type or a fully qualified + Java class name (including package name), + as per the 'Type' production in the Java + Language Specification, Second Edition, + Chapter 18. + + * Identifier is a Java identifier, as per + the 'Identifier' production in the Java + Language Specification, Second + Edition, Chapter 18. + + Example: + + java.lang.String nickName( java.lang.String, int ) + + + + + + + + + The example element contains an informal description + of an example of the use of this function. + + + + + + + + + Function extensions are for tool use only and must not + affect the behavior of a container. + + + + + + + + + + + + + + + + The taglib tag is the document root, it defines: + + description a simple string describing the "use" of this + taglib, should be user discernable + + display-name the display-name element contains a + short name that is intended to be displayed + by tools + + icon optional icon that can be used by tools + + tlib-version the version of the tag library implementation + + short-name a simple default short name that could be + used by a JSP authoring tool to create + names with a mnemonic value; for example, + the it may be used as the prefered prefix + value in taglib directives + + uri a uri uniquely identifying this taglib + + validator optional TagLibraryValidator information + + listener optional event listener specification + + tag tags in this tag library + + tag-file tag files in this tag library + + function zero or more EL functions defined in this + tag library + + taglib-extension zero or more extensions that provide extra + information about this taglib, for tool + consumption + + + + + + + + + + Describes this version (number) of the taglibrary. + It is described as a dewey decimal. + + + + + + + + + Defines a simple default name that could be used by + a JSP authoring tool to create names with a + mnemonicvalue; for example, it may be used as the + preferred prefix value in taglib directives. Do + not use white space, and do not start with digits + or underscore. + + + + + + + + + Defines a public URI that uniquely identifies this + version of the taglibrary. Leave it empty if it + does not apply. + + + + + + + + + + + + + + + + Taglib extensions are for tool use only and must not + affect the behavior of a container. + + + + + + + + + + Describes the JSP version (number) this taglibrary + requires in order to function (dewey decimal) + + + + + + + + + + + + + + + The variableType provides information on the scripting + variables defined by using this tag. It is a (translation + time) error for a tag that has one or more variable + subelements to have a TagExtraInfo class that returns a + non-null value from a call to getVariableInfo(). + + The subelements of variableType are of the form: + + description Optional description of this + variable + + name-given The variable name as a constant + + name-from-attribute The name of an attribute whose + (translation time) value will + give the name of the + variable. One of name-given or + name-from-attribute is required. + + variable-class Name of the class of the variable. + java.lang.String is default. + + declare Whether the variable is declared + or not. True is the default. + + scope The scope of the scripting varaible + defined. NESTED is default. + + + + + + + + + + + The name for the scripting variable. + + + + + + + + + The name of an attribute whose + (translation-time) value will give the name of + the variable. + + + + + + + + + + The optional name of the class for the scripting + variable. The default is java.lang.String. + + + + + + + + + Whether the scripting variable is to be defined + or not. See TagExtraInfo for details. This + element is optional and "true" is the default. + + + + + + + + + The element is optional and "NESTED" is the default. + + + + + + + + + + + + + + + + This type defines scope of the scripting variable. See + TagExtraInfo for details. The allowed values are, + "NESTED", "AT_BEGIN" and "AT_END". + + + + + + + + + + + + + + + + + + + + The attribute element defines an attribute for the nesting + tag. The attribute element may have several subelements + defining: + + description a description of the attribute + + name the name of the attribute + + required whether the attribute is required or + optional + + rtexprvalue whether the attribute is a runtime attribute + + type the type of the attributes + + fragment whether this attribute is a fragment + + deferred-value present if this attribute is to be parsed as a + jakarta.el.ValueExpression + + deferred-method present if this attribute is to be parsed as a + jakarta.el.MethodExpression + + + + + + + + + + + Defines if the nesting attribute is required or + optional. + + If not present then the default is "false", i.e + the attribute is optional. + + + + + + + + + + + + Defines if the nesting attribute can have scriptlet + expressions as a value, i.e the value of the + attribute may be dynamically calculated at request + time, as opposed to a static value determined at + translation time. + If not present then the default is "false", i.e the + attribute has a static value + + + + + + + + + Defines the Java type of the attributes value. + If this element is omitted, the expected type is + assumed to be "java.lang.Object". + + + + + + + + + + + Present if the value for this attribute is to be + passed to the tag handler as a + jakarta.el.ValueExpression. This allows for deferred + evaluation of EL expressions. An optional subelement + will contain the expected type that the value will + be coerced to after evaluation of the expression. + The type defaults to Object if one is not provided. + + + + + + + + + Present if the value for this attribute is to be + passed to the tag handler as a + jakarta.el.MethodExpression. This allows for deferred + evaluation of an EL expression that identifies a + method to be invoked on an Object. An optional + subelement will contain the expected method + signature. The signature defaults to "void method()" + if one is not provided. + + + + + + + + + + + "true" if this attribute is of type + jakarta.servlet.jsp.tagext.JspFragment, representing dynamic + content that can be re-evaluated as many times + as needed by the tag handler. If omitted or "false", + the default is still type="java.lang.String" + + + + + + + + + + + + + + + + + Defines information about how to provide the value for a + tag handler attribute that accepts a jakarta.el.ValueExpression. + + The deferred-value element has one optional subelement: + + type the expected type of the attribute + + + + + + + + + The fully-qualified name of the Java type that is the + expected type for this deferred expression. If this + element is omitted, the expected type is assumed to be + "java.lang.Object". + + + + + + + + + + + + + + + + Defines information about how to provide the value for a + tag handler attribute that accepts a jakarta.el.MethodExpression. + + The deferred-method element has one optional subelement: + + method-signature Provides the signature, as in the Java + Language Specifies, that is expected for + the method being identified by the + expression. + + + + + + + + + Provides the expected signature of the method identified + by the jakarta.el.MethodExpression. + + This disambiguates overloaded methods and ensures that + the return value is of the expected type. + + The syntax of the method-signature element is identical + to that of the function-signature element. See the + documentation for function-signature for more details. + + The name of the method is for documentation purposes only + and is ignored by the JSP container. + + Example: + + boolean validate(java.lang.String) + + + + + + + + + + + + + + + + The tld-extensionType is used to indicate + extensions to a specific TLD element. + + It is used by elements to designate an extension block + that is targeted to a specific extension designated by + a set of extension elements that are declared by a + namespace. The namespace identifies the extension to + the tool that processes the extension. + + The type of the extension-element is abstract. Therefore, + a concrete type must be specified by the TLD using + xsi:type attribute for each extension-element. + + + + + + + + + + + + + + + + + + The extensibleType is an abstract base type that is used to + define the type of extension-elements. Instance documents + must substitute a known type to define the extension by + using xsi:type attribute to define the actual type of + extension-elements. + + + + + + + diff --git a/grails-web-taglib/build.gradle b/grails-web-taglib/build.gradle index 23091c3c28..c45af94483 100644 --- a/grails-web-taglib/build.gradle +++ b/grails-web-taglib/build.gradle @@ -1,5 +1,5 @@ dependencies { - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" + compileOnly "jakarta.servlet:jakarta.servlet-api:$servletApiVersion" api "org.grails:grails-web-common:$grailsVersion" api project(":grails-taglib") diff --git a/grails-web-taglib/src/main/groovy/grails/artefact/TagLibrary.groovy b/grails-web-taglib/src/main/groovy/grails/artefact/TagLibrary.groovy index d9852f2c9f..ace47503fb 100644 --- a/grails-web-taglib/src/main/groovy/grails/artefact/TagLibrary.groovy +++ b/grails-web-taglib/src/main/groovy/grails/artefact/TagLibrary.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -37,7 +37,7 @@ import org.grails.taglib.TagLibraryMetaUtils import org.grails.web.util.GrailsApplicationAttributes import org.springframework.web.context.request.RequestAttributes -import javax.annotation.PostConstruct +import jakarta.annotation.PostConstruct /** * A trait that makes a class into a GSP tag library * diff --git a/grails-web-taglib/src/main/groovy/org/grails/web/taglib/encoder/WebOutputContextLookup.java b/grails-web-taglib/src/main/groovy/org/grails/web/taglib/encoder/WebOutputContextLookup.java index ac4a06e3cd..73f6f743d4 100644 --- a/grails-web-taglib/src/main/groovy/org/grails/web/taglib/encoder/WebOutputContextLookup.java +++ b/grails-web-taglib/src/main/groovy/org/grails/web/taglib/encoder/WebOutputContextLookup.java @@ -1,11 +1,11 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -31,7 +31,7 @@ import org.springframework.core.Ordered; import org.springframework.web.context.request.RequestAttributes; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import java.io.Writer; public class WebOutputContextLookup implements OutputContextLookup, Ordered {