Skip to content

Commit

Permalink
Dropped support for very old Servlet and JSP versions, and now requir…
Browse files Browse the repository at this point in the history
…ing at least Servlet 3.0 and JSP 2.2. This way, we only need to support a single javax Servlet/JSP version, and could remove the complications from supporting multiple old versions. Also, with this, the "jsp20" and "jsp21" Gradle configurations were unified as "javaxServlet" (because later we want to have "jakartaServlet" too).
  • Loading branch information
ddekany committed Dec 25, 2023
1 parent 1c465db commit 6515986
Show file tree
Hide file tree
Showing 112 changed files with 206 additions and 417 deletions.
33 changes: 14 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ tasks.withType<JavaCompile>().configureEach {

freemarkerRoot {
configureSourceSet(SourceSet.MAIN_SOURCE_SET_NAME) { enableTests() }
configureSourceSet("jsp20")
configureSourceSet("jsp21") { enableTests() }
configureSourceSet("javaxServlet") { enableTests() }
configureSourceSet("jython20")
configureSourceSet("jython22")
configureSourceSet("jython25") { enableTests() }
Expand Down Expand Up @@ -105,7 +104,7 @@ tasks.jar.configure {
configurations {
register("combinedClasspath") {
extendsFrom(named("jython25CompileClasspath").get())
extendsFrom(named("jsp21CompileClasspath").get())
extendsFrom(named("javaxServletCompileClasspath").get())
}
}

Expand Down Expand Up @@ -494,7 +493,7 @@ eclipse {
configurations["combinedClasspath"],
configurations["core16CompileClasspath"],
configurations["testUtilsCompileClasspath"],
configurations["jsp21TestCompileClasspath"]
configurations["javaxServletTestCompileClasspath"]
)
}
}
Expand All @@ -515,7 +514,7 @@ configurations {
exclude(group = "xml-apis", module = "xml-apis")
}

"jsp21TestImplementation" {
"javaxServletTestImplementation" {
extendsFrom(compileClasspath.get())
exclude(group = "javax.servlet.jsp")
exclude(group = "javax.servlet", module = "servlet-api")
Expand Down Expand Up @@ -544,27 +543,23 @@ dependencies {

testImplementation(xalan)

"jsp20CompileOnly"("javax.servlet.jsp:jsp-api:2.0")
"jsp20CompileOnly"("javax.servlet:servlet-api:2.4")
"javaxServletCompileOnly"("javax.servlet.jsp:jsp-api:2.1")
"javaxServletCompileOnly"("javax.servlet:servlet-api:2.5")

"jsp21CompileOnly"(sourceSets["jsp20"].output)
"jsp21CompileOnly"("javax.servlet.jsp:jsp-api:2.1")
"jsp21CompileOnly"("javax.servlet:servlet-api:2.5")

"jsp21TestImplementation"("org.eclipse.jetty:jetty-server:${jettyVersion}")
"jsp21TestImplementation"("org.eclipse.jetty:jetty-webapp:${jettyVersion}")
"jsp21TestImplementation"("org.eclipse.jetty:jetty-util:${jettyVersion}")
"jsp21TestImplementation"("org.eclipse.jetty:apache-jsp:${jettyVersion}")
"javaxServletTestImplementation"("org.eclipse.jetty:jetty-server:${jettyVersion}")
"javaxServletTestImplementation"("org.eclipse.jetty:jetty-webapp:${jettyVersion}")
"javaxServletTestImplementation"("org.eclipse.jetty:jetty-util:${jettyVersion}")
"javaxServletTestImplementation"("org.eclipse.jetty:apache-jsp:${jettyVersion}")
// Jetty also contains the servlet-api and jsp-api classes

// JSP JSTL (not included in Jetty):
"jsp21TestImplementation"("org.apache.taglibs:taglibs-standard-impl:${tagLibsVersion}")
"jsp21TestImplementation"("org.apache.taglibs:taglibs-standard-spec:${tagLibsVersion}")
"javaxServletTestImplementation"("org.apache.taglibs:taglibs-standard-impl:${tagLibsVersion}")
"javaxServletTestImplementation"("org.apache.taglibs:taglibs-standard-spec:${tagLibsVersion}")

"jsp21TestImplementation"("org.springframework:spring-core:${springVersion}") {
"javaxServletTestImplementation"("org.springframework:spring-core:${springVersion}") {
exclude(group = "commons-logging", module = "commons-logging")
}
"jsp21TestImplementation"("org.springframework:spring-test:${springVersion}") {
"javaxServletTestImplementation"("org.springframework:spring-test:${springVersion}") {
exclude(group = "commons-logging", module = "commons-logging")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@
package freemarker.ext.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;

/**
*/
abstract class FreeMarkerJspFactory extends JspFactory {
protected abstract String getSpecificationVersion();
class FreeMarkerJspFactory extends JspFactory {
private static final String SPECIFICATION_VERSION = "2.2";
private static final String JSPCTX_KEY = "freemarker.ext.jsp.FreeMarkerJspFactory21#jspAppContext";

protected String getSpecificationVersion() {
return SPECIFICATION_VERSION;
}

@Override
public JspEngineInfo getEngineInfo() {
Expand Down Expand Up @@ -60,4 +65,21 @@ public void releasePageContext(PageContext ctx) {
// for this API.
throw new UnsupportedOperationException();
}

@Override
public JspApplicationContext getJspApplicationContext(ServletContext ctx) {
JspApplicationContext jspctx = (JspApplicationContext) ctx.getAttribute(
JSPCTX_KEY);
if (jspctx == null) {
synchronized (ctx) {
jspctx = (JspApplicationContext) ctx.getAttribute(JSPCTX_KEY);
if (jspctx == null) {
jspctx = new FreeMarkerJspApplicationContext();
ctx.setAttribute(JSPCTX_KEY, jspctx);
}
}
}
return jspctx;
}

}
Loading

0 comments on commit 6515986

Please sign in to comment.