This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new ec8bca496c Fix compatibility with tag files
ec8bca496c is described below
commit ec8bca496c6233b81b1b30d4a073a16b63dd6cb4
Author: remm <[email protected]>
AuthorDate: Tue Sep 1 15:04:37 2026 +0200
Fix compatibility with tag files
Some other plugins were fine.
Found by code review.
---
.../apache/jasper/tagplugins/jstl/core/Catch.java | 7 +--
.../jasper/tagplugins/jstl/core/ForTokens.java | 2 +-
.../apache/jasper/tagplugins/jstl/core/Import.java | 50 +++++++++++-----------
.../apache/jasper/tagplugins/jstl/core/Param.java | 7 +--
.../jasper/tagplugins/jstl/core/Redirect.java | 12 +++---
.../apache/jasper/tagplugins/jstl/core/Remove.java | 4 +-
.../apache/jasper/tagplugins/jstl/core/Url.java | 14 +++---
7 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
index 173e336c92..4e1a4dc0b6 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
@@ -53,8 +53,8 @@ public class Catch implements TagPlugin {
// be set to the attribute "var" defines in page scope
if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource(
- " pageContext.setAttribute(\"" + strVar + "\", " +
exceptionName + ", PageContext.PAGE_SCOPE);");
+ ctxt.generateJavaSource(" _jspx_page_context.setAttribute(\"" +
strVar + "\", " +
+ exceptionName + ", PageContext.PAGE_SCOPE);");
}
// whenever there's exception caught,
@@ -70,7 +70,8 @@ public class Catch implements TagPlugin {
if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(" if(!" + caughtName + "){");
- ctxt.generateJavaSource(" pageContext.removeAttribute(\"" +
strVar + "\", PageContext.PAGE_SCOPE);");
+ ctxt.generateJavaSource("
_jspx_page_context.removeAttribute(\"" + strVar +
+ "\", PageContext.PAGE_SCOPE);");
ctxt.generateJavaSource(" }");
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
index 03bb4a0ea2..8ae2858edb 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
@@ -119,7 +119,7 @@ public class ForTokens implements TagPlugin {
// if var specified, put the current token into the attribute "var"
defines.
if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource(" pageContext.setAttribute(\"" +
strVar + "\", " + temp + ");");
+ ctxt.generateJavaSource("
_jspx_page_context.setAttribute(\"" + strVar + "\", " + temp + ");");
}
ctxt.generateBody();
ctxt.generateJavaSource(" }");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Import.java
b/java/org/apache/jasper/tagplugins/jstl/core/Import.java
index 476f1763c2..3f564c805d 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Import.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Import.java
@@ -119,7 +119,7 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource("if(!" + iauName + "){");
ctxt.generateJavaSource(" if(!" + urlName + ".startsWith(\"/\")){");
ctxt.generateJavaSource(" String " + servletPathName + " = " +
-
"((HttpServletRequest)pageContext.getRequest()).getServletPath();");
+
"((HttpServletRequest)_jspx_page_context.getRequest()).getServletPath();");
ctxt.generateJavaSource(" " + urlName + " = " + servletPathName
+ ".substring(0," + servletPathName +
".lastIndexOf('/')) + '/' + " + urlName + ";");
ctxt.generateJavaSource(" }");
@@ -182,14 +182,15 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource(" }");
// set attribute in the page context scope
- ctxt.generateJavaSource(" pageContext.setAttribute(" +
varReaderName + ", " + tempReaderName + ");");
+ ctxt.generateJavaSource(" _jspx_page_context.setAttribute(" +
varReaderName + ", " +
+ tempReaderName + ");");
// if the url is relative
ctxt.generateJavaSource("}else{");
// if the url is relative, http request is needed
- ctxt.generateJavaSource(" if (!(pageContext.getRequest()
instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof
HttpServletResponse)){");
+ ctxt.generateJavaSource(" if (!(_jspx_page_context.getRequest()
instanceof HttpServletRequest " +
+ "&& _jspx_page_context.getResponse() instanceof
HttpServletResponse)){");
ctxt.generateJavaSource(
" throw new JspTagException(\"Relative
<import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
@@ -199,12 +200,12 @@ public class Import implements TagPlugin {
if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName +
"){");
ctxt.generateJavaSource(" " + servletContextName +
- " = pageContext.getServletContext().getContext(" +
contextName + ");");
+ " =
_jspx_page_context.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + servletContextName + " =
pageContext.getServletContext();");
+ ctxt.generateJavaSource(" " + servletContextName + " =
_jspx_page_context.getServletContext();");
ctxt.generateJavaSource(" }");
} else {
- ctxt.generateJavaSource(" " + servletContextName + " =
pageContext.getServletContext();");
+ ctxt.generateJavaSource(" " + servletContextName + " =
_jspx_page_context.getServletContext();");
}
//
@@ -230,7 +231,7 @@ public class Import implements TagPlugin {
// initialize a ImportResponseWrapper to include the resource
ctxt.generateJavaSource("
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName +
- " = new
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse)
pageContext.getResponse());");
+ " = new
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse)
_jspx_page_context.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
ctxt.generateJavaSource(
" " + charSetName + " =
org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
@@ -238,7 +239,7 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" +
charSetName + ");");
ctxt.generateJavaSource(" try{");
ctxt.generateJavaSource(
- " " + requestDispatcherName +
".include(pageContext.getRequest(), " + irwName + ");");
+ " " + requestDispatcherName +
".include(_jspx_page_context.getRequest(), " + irwName + ");");
ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
ctxt.generateJavaSource(" throw new JspException(ex);");
ctxt.generateJavaSource(" }catch(RuntimeException ex){");
@@ -260,7 +261,8 @@ public class Import implements TagPlugin {
// push in the page context
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + "
= new java.io.StringReader(" + irwName +
".getString());");
- ctxt.generateJavaSource(" pageContext.setAttribute(" +
varReaderName + ", " + tempReaderName + ");");
+ ctxt.generateJavaSource(" _jspx_page_context.setAttribute(" +
varReaderName + ", " +
+ tempReaderName + ");");
ctxt.generateJavaSource("}");
@@ -269,18 +271,18 @@ public class Import implements TagPlugin {
// close the reader
ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 +
- " = (java.io.Reader)pageContext.getAttribute(" +
varReaderName + ");");
+ " = (java.io.Reader)_jspx_page_context.getAttribute(" +
varReaderName + ");");
ctxt.generateJavaSource("if(" + tempReaderName2 + " != null) " +
tempReaderName2 + ".close();");
- ctxt.generateJavaSource("pageContext.removeAttribute(" +
varReaderName + ",1);");
+ ctxt.generateJavaSource("_jspx_page_context.removeAttribute(" +
varReaderName + ",1);");
}
// if the varReader is not specified
else {
-
ctxt.generateJavaSource("pageContext.setAttribute(\"url_without_param\"," +
urlName + ");");
+
ctxt.generateJavaSource("_jspx_page_context.setAttribute(\"url_without_param\","
+ urlName + ");");
ctxt.generateBody();
- ctxt.generateJavaSource(urlName + " =
(String)pageContext.getAttribute(\"url_without_param\");");
-
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource(urlName + " =
(String)_jspx_page_context.getAttribute(\"url_without_param\");");
+
ctxt.generateJavaSource("_jspx_page_context.removeAttribute(\"url_without_param\");");
String strScope = "page";
if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
@@ -341,8 +343,8 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource("}else{");
// if the url is relative, http request is needed.
- ctxt.generateJavaSource(" if (!(pageContext.getRequest()
instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof
HttpServletResponse)){");
+ ctxt.generateJavaSource(" if (!(_jspx_page_context.getRequest()
instanceof HttpServletRequest " +
+ "&& _jspx_page_context.getResponse() instanceof
HttpServletResponse)){");
ctxt.generateJavaSource(
" throw new JspTagException(\"Relative
<import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
@@ -352,12 +354,12 @@ public class Import implements TagPlugin {
if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName +
"){");
ctxt.generateJavaSource(" " + servletContextName +
- " = pageContext.getServletContext().getContext(" +
contextName + ");");
+ " =
_jspx_page_context.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + servletContextName + " =
pageContext.getServletContext();");
+ ctxt.generateJavaSource(" " + servletContextName + " =
_jspx_page_context.getServletContext();");
ctxt.generateJavaSource(" }");
} else {
- ctxt.generateJavaSource(" " + servletContextName + " =
pageContext.getServletContext();");
+ ctxt.generateJavaSource(" " + servletContextName + " =
_jspx_page_context.getServletContext();");
}
//
@@ -383,7 +385,7 @@ public class Import implements TagPlugin {
// initialize a ImportResponseWrapper to include the resource
ctxt.generateJavaSource("
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName +
- " = new
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse)
pageContext.getResponse());");
+ " = new
org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse)
_jspx_page_context.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
ctxt.generateJavaSource(
" " + charSetName + " =
org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
@@ -391,7 +393,7 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" +
charSetName + ");");
ctxt.generateJavaSource(" try{");
ctxt.generateJavaSource(
- " " + requestDispatcherName +
".include(pageContext.getRequest(), " + irwName + ");");
+ " " + requestDispatcherName +
".include(_jspx_page_context.getRequest(), " + irwName + ");");
ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
ctxt.generateJavaSource(" throw new JspException(ex);");
ctxt.generateJavaSource(" }catch(RuntimeException ex){");
@@ -417,9 +419,9 @@ public class Import implements TagPlugin {
if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(
- "pageContext.setAttribute(\"" + strVar + "\"," +
tempStringName + "," + iScope + ");");
+ "_jspx_page_context.setAttribute(\"" + strVar + "\","
+ tempStringName + "," + iScope + ");");
} else {
- ctxt.generateJavaSource("pageContext.getOut().print(" +
tempStringName + ");");
+ ctxt.generateJavaSource("_jspx_page_context.getOut().print(" +
tempStringName + ");");
}
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Param.java
b/java/org/apache/jasper/tagplugins/jstl/core/Param.java
index 10fcb79525..006bf2675d 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Param.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Param.java
@@ -54,7 +54,7 @@ public class Param implements TagPlugin {
// get the url string before adding this param
ctxt.generateJavaSource(
- "String " + urlName + " = " +
"(String)pageContext.getAttribute(\"url_without_param\");");
+ "String " + urlName + " = " +
"(String)_jspx_page_context.getAttribute(\"url_without_param\");");
// get the value of "name"
ctxt.generateJavaSource("String " + nameName + " = ");
@@ -69,7 +69,8 @@ public class Param implements TagPlugin {
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
ctxt.generateJavaSource(" if(" + valueName + " == null) " +
valueName + " = \"\";");
- ctxt.generateJavaSource(" String " + encName + " =
pageContext.getResponse().getCharacterEncoding();");
+ ctxt.generateJavaSource(
+ " String " + encName + " =
_jspx_page_context.getResponse().getCharacterEncoding();");
ctxt.generateJavaSource(
" " + nameName + " = java.net.URLEncoder.encode(" +
nameName + ", " + encName + ");");
ctxt.generateJavaSource(
@@ -85,7 +86,7 @@ public class Param implements TagPlugin {
ctxt.generateJavaSource(
" " + urlName + " = " + urlName + " + \"&\" + " +
nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }");
- ctxt.generateJavaSource("
pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
+ ctxt.generateJavaSource("
_jspx_page_context.setAttribute(\"url_without_param\"," + urlName + ");");
ctxt.generateJavaSource("}");
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
index 6d55726862..be30d71b71 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
@@ -59,19 +59,19 @@ public class Redirect implements TagPlugin {
// get the raw url according to "url" and "context"
ctxt.generateJavaSource("String " + baseUrlName + " = " +
"org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" +
- urlName + ", " + contextName + ", pageContext);");
- ctxt.generateJavaSource("pageContext.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
+ urlName + ", " + contextName + ", _jspx_page_context);");
+ ctxt.generateJavaSource("_jspx_page_context.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
// add params
ctxt.generateBody();
ctxt.generateJavaSource(
- "String " + resultName + " = " +
"(String)pageContext.getAttribute(\"url_without_param\");");
- ctxt.generateJavaSource("pageContext.removeAttribute" +
"(\"url_without_param\");");
+ "String " + resultName + " = " +
"(String)_jspx_page_context.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource("_jspx_page_context.removeAttribute" +
"(\"url_without_param\");");
// get the response object
- ctxt.generateJavaSource(
- "HttpServletResponse " + responseName + " = " +
"((HttpServletResponse) pageContext.getResponse());");
+ ctxt.generateJavaSource("HttpServletResponse " + responseName + " = " +
+ "((HttpServletResponse) _jspx_page_context.getResponse());");
// if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl("
+ resultName + ")){");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
index 968c23461d..4e8e3a1762 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
@@ -44,9 +44,9 @@ public class Remove implements TagPlugin {
// default scope is "page".
if (hasScope) {
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
- ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar
+ "\"," + iScope + ");");
+ ctxt.generateJavaSource("_jspx_page_context.removeAttribute(\"" +
strVar + "\"," + iScope + ");");
} else {
- ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar
+ "\");");
+ ctxt.generateJavaSource("_jspx_page_context.removeAttribute(\"" +
strVar + "\");");
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Url.java
b/java/org/apache/jasper/tagplugins/jstl/core/Url.java
index 83dec3392d..8538208df0 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Url.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Url.java
@@ -71,20 +71,20 @@ public class Url implements TagPlugin {
// get the raw url
ctxt.generateJavaSource("String " + baseUrlName + " = " +
"org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" +
- valueName + ", " + contextName + ", pageContext);");
- ctxt.generateJavaSource("pageContext.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
+ valueName + ", " + contextName + ", _jspx_page_context);");
+ ctxt.generateJavaSource("_jspx_page_context.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
// add params
ctxt.generateBody();
ctxt.generateJavaSource(
- "String " + resultName + " = " +
"(String)pageContext.getAttribute(\"url_without_param\");");
-
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
+ "String " + resultName + " = " +
"(String)_jspx_page_context.getAttribute(\"url_without_param\");");
+
ctxt.generateJavaSource("_jspx_page_context.removeAttribute(\"url_without_param\");");
// if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl("
+ resultName + ")){");
ctxt.generateJavaSource(" HttpServletResponse " + responseName + "
= " +
- "((HttpServletResponse) pageContext.getResponse());");
+ "((HttpServletResponse) _jspx_page_context.getResponse());");
ctxt.generateJavaSource(" " + resultName + " = " + responseName +
".encodeURL(" + resultName + ");");
ctxt.generateJavaSource("}");
@@ -92,12 +92,12 @@ public class Url implements TagPlugin {
if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(
- "pageContext.setAttribute" + "(\"" + strVar + "\", " +
resultName + ", " + iScope + ");");
+ "_jspx_page_context.setAttribute" + "(\"" + strVar + "\",
" + resultName + ", " + iScope + ");");
// if var is not specified, just print out the url string
} else {
ctxt.generateJavaSource("try{");
- ctxt.generateJavaSource(" pageContext.getOut().print(" +
resultName + ");");
+ ctxt.generateJavaSource(" _jspx_page_context.getOut().print(" +
resultName + ");");
ctxt.generateJavaSource("}catch(java.io.IOException ex){");
ctxt.generateJavaSource(" throw new
JspTagException(ex.toString(), ex);");
ctxt.generateJavaSource("}");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]