You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/03/06 16:19:16 UTC
(tomcat) branch 9.0.x updated (184089db14 -> 92d62d6d8f)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from 184089db14 Remove comments related to the ability to inline these methods.
new fbba100186 Fix backport.
new 92d62d6d8f Code clean-up - formatting. No functional change.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/jasper/runtime/BodyContentImpl.java | 76 ++--
java/org/apache/jasper/runtime/ExceptionUtils.java | 10 +-
java/org/apache/jasper/runtime/HttpJspBase.java | 12 +-
.../jasper/runtime/JspApplicationContextImpl.java | 9 +-
.../apache/jasper/runtime/JspContextWrapper.java | 116 +++---
java/org/apache/jasper/runtime/JspFactoryImpl.java | 58 ++-
.../apache/jasper/runtime/JspFragmentHelper.java | 18 +-
.../apache/jasper/runtime/JspRuntimeLibrary.java | 423 +++++++++------------
.../apache/jasper/runtime/JspSourceDependent.java | 14 +-
.../apache/jasper/runtime/JspSourceImports.java | 8 +-
java/org/apache/jasper/runtime/JspWriterImpl.java | 74 ++--
.../org/apache/jasper/runtime/PageContextImpl.java | 217 +++++------
.../jasper/runtime/ProtectedFunctionMapper.java | 78 ++--
.../runtime/ServletResponseWrapperInclude.java | 15 +-
java/org/apache/jasper/runtime/TagHandlerPool.java | 29 +-
15 files changed, 482 insertions(+), 675 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/02: Fix backport.
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit fbba100186325251038b3f8cf2336aa04b0ce82c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 6 16:17:37 2025 +0000
Fix backport.
---
.../org/apache/jasper/runtime/JspRuntimeLibrary.java | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index c2931821d4..559e5366ca 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -19,10 +19,9 @@ package org.apache.jasper.runtime;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import javax.servlet.RequestDispatcher;
@@ -1004,14 +1003,19 @@ public class JspRuntimeLibrary {
if (enc == null) {
enc = "ISO-8859-1"; // The default request encoding
}
- Charset cs = null;
+ String result = null;
+
try {
- cs = Charset.forName(enc);
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- cs = StandardCharsets.ISO_8859_1;
+ result = URLEncoder.encode(s, enc);
+ } catch (UnsupportedEncodingException uee) {
+ // Fallback to default.
+ try {
+ result = URLEncoder.encode(s, "ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ /// Should never happen.
+ }
}
- return URLEncoder.encode(s, cs);
+ return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/02: Code clean-up - formatting. No functional change.
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 92d62d6d8f0f8c3a7eedab5386b43176323b2c1f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 6 16:19:11 2025 +0000
Code clean-up - formatting. No functional change.
---
.../org/apache/jasper/runtime/BodyContentImpl.java | 76 ++--
java/org/apache/jasper/runtime/ExceptionUtils.java | 10 +-
java/org/apache/jasper/runtime/HttpJspBase.java | 12 +-
.../jasper/runtime/JspApplicationContextImpl.java | 9 +-
.../apache/jasper/runtime/JspContextWrapper.java | 116 +++---
java/org/apache/jasper/runtime/JspFactoryImpl.java | 58 ++-
.../apache/jasper/runtime/JspFragmentHelper.java | 18 +-
.../apache/jasper/runtime/JspRuntimeLibrary.java | 403 ++++++++-------------
.../apache/jasper/runtime/JspSourceDependent.java | 14 +-
.../apache/jasper/runtime/JspSourceImports.java | 8 +-
java/org/apache/jasper/runtime/JspWriterImpl.java | 74 ++--
.../org/apache/jasper/runtime/PageContextImpl.java | 217 +++++------
.../jasper/runtime/ProtectedFunctionMapper.java | 78 ++--
.../runtime/ServletResponseWrapperInclude.java | 15 +-
java/org/apache/jasper/runtime/TagHandlerPool.java | 29 +-
15 files changed, 470 insertions(+), 667 deletions(-)
diff --git a/java/org/apache/jasper/runtime/BodyContentImpl.java b/java/org/apache/jasper/runtime/BodyContentImpl.java
index 007a78609f..620005c51e 100644
--- a/java/org/apache/jasper/runtime/BodyContentImpl.java
+++ b/java/org/apache/jasper/runtime/BodyContentImpl.java
@@ -30,11 +30,8 @@ import org.apache.jasper.Constants;
import org.apache.jasper.compiler.Localizer;
/**
- * Write text to a character-output stream, buffering characters so as
- * to provide for the efficient writing of single characters, arrays,
- * and strings.
- *
- * Provide support for discarding for the output that has been buffered.
+ * Write text to a character-output stream, buffering characters so as to provide for the efficient writing of single
+ * characters, arrays, and strings. Provide support for discarding for the output that has been buffered.
*
* @author Rajiv Mordani
* @author Jan Luehe
@@ -46,32 +43,25 @@ public class BodyContentImpl extends BodyContent {
static {
if (System.getSecurityManager() == null) {
- LIMIT_BUFFER = Boolean.parseBoolean(System.getProperty(
- "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false"));
- TAG_BUFFER_SIZE = Integer.getInteger(
- "org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE",
+ LIMIT_BUFFER = Boolean.parseBoolean(
+ System.getProperty("org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false"));
+ TAG_BUFFER_SIZE = Integer.getInteger("org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE",
Constants.DEFAULT_TAG_BUFFER_SIZE).intValue();
} else {
- LIMIT_BUFFER = AccessController.doPrivileged(
- new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return Boolean.valueOf(System.getProperty(
- "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER",
- "false"));
- }
- }
- ).booleanValue();
- TAG_BUFFER_SIZE = AccessController.doPrivileged(
- new PrivilegedAction<Integer>() {
- @Override
- public Integer run() {
- return Integer.getInteger(
- "org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE",
- Constants.DEFAULT_TAG_BUFFER_SIZE);
- }
- }
- ).intValue();
+ LIMIT_BUFFER = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ @Override
+ public Boolean run() {
+ return Boolean.valueOf(
+ System.getProperty("org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false"));
+ }
+ }).booleanValue();
+ TAG_BUFFER_SIZE = AccessController.doPrivileged(new PrivilegedAction<Integer>() {
+ @Override
+ public Integer run() {
+ return Integer.getInteger("org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE",
+ Constants.DEFAULT_TAG_BUFFER_SIZE);
+ }
+ }).intValue();
}
}
@@ -87,6 +77,7 @@ public class BodyContentImpl extends BodyContent {
/**
* Constructor.
+ *
* @param enclosingWriter The wrapped writer
*/
public BodyContentImpl(JspWriter enclosingWriter) {
@@ -104,7 +95,7 @@ public class BodyContentImpl extends BodyContent {
} else {
ensureOpen();
if (nextChar >= bufferSize) {
- reAllocBuff (1);
+ reAllocBuff(1);
}
cb[nextChar++] = (char) c;
}
@@ -117,19 +108,18 @@ public class BodyContentImpl extends BodyContent {
} else {
ensureOpen();
- if ((off < 0) || (off > cbuf.length) || (len < 0) ||
- ((off + len) > cbuf.length) || ((off + len) < 0)) {
+ if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
if (len >= bufferSize - nextChar) {
- reAllocBuff (len);
+ reAllocBuff(len);
}
System.arraycopy(cbuf, off, cb, nextChar, len);
- nextChar+=len;
+ nextChar += len;
}
}
@@ -295,7 +285,7 @@ public class BodyContentImpl extends BodyContent {
}
@Override
- public void println(double x) throws IOException{
+ public void println(double x) throws IOException {
print(x);
println();
}
@@ -358,12 +348,12 @@ public class BodyContentImpl extends BodyContent {
@Override
public int getRemaining() {
- return (writer == null) ? bufferSize-nextChar : 0;
+ return (writer == null) ? bufferSize - nextChar : 0;
}
@Override
public Reader getReader() {
- return (writer == null) ? new CharArrayReader (cb, 0, nextChar) : null;
+ return (writer == null) ? new CharArrayReader(cb, 0, nextChar) : null;
}
@Override
@@ -392,13 +382,11 @@ public class BodyContentImpl extends BodyContent {
}
/**
- * This method shall "reset" the internal state of a BodyContentImpl,
- * releasing all internal references, and preparing it for potential
- * reuse by a later invocation of {@link PageContextImpl#pushBody(Writer)}.
- *
- * <p>Note, that BodyContentImpl instances are usually owned by a
- * PageContextImpl instance, and PageContextImpl instances are recycled
- * and reused.
+ * This method shall "reset" the internal state of a BodyContentImpl, releasing all internal references, and
+ * preparing it for potential reuse by a later invocation of {@link PageContextImpl#pushBody(Writer)}.
+ * <p>
+ * Note, that BodyContentImpl instances are usually owned by a PageContextImpl instance, and PageContextImpl
+ * instances are recycled and reused.
*
* @see PageContextImpl#release()
*/
diff --git a/java/org/apache/jasper/runtime/ExceptionUtils.java b/java/org/apache/jasper/runtime/ExceptionUtils.java
index 344bce2aa5..dbfde2d278 100644
--- a/java/org/apache/jasper/runtime/ExceptionUtils.java
+++ b/java/org/apache/jasper/runtime/ExceptionUtils.java
@@ -25,8 +25,8 @@ import java.lang.reflect.InvocationTargetException;
public class ExceptionUtils {
/**
- * Checks whether the supplied Throwable is one that needs to be
- * rethrown and swallows all others.
+ * Checks whether the supplied Throwable is one that needs to be rethrown and swallows all others.
+ *
* @param t the Throwable to check
*/
public static void handleThrowable(Throwable t) {
@@ -44,11 +44,11 @@ public class ExceptionUtils {
}
/**
- * Checks whether the supplied Throwable is an instance of
- * <code>InvocationTargetException</code> and returns the throwable that is
- * wrapped by it, if there is any.
+ * Checks whether the supplied Throwable is an instance of <code>InvocationTargetException</code> and returns the
+ * throwable that is wrapped by it, if there is any.
*
* @param t the Throwable to check
+ *
* @return <code>t</code> or <code>t.getCause()</code>
*/
public static Throwable unwrapInvocationTargetException(Throwable t) {
diff --git a/java/org/apache/jasper/runtime/HttpJspBase.java b/java/org/apache/jasper/runtime/HttpJspBase.java
index 7f6c8b20ce..51a086989f 100644
--- a/java/org/apache/jasper/runtime/HttpJspBase.java
+++ b/java/org/apache/jasper/runtime/HttpJspBase.java
@@ -41,9 +41,7 @@ public abstract class HttpJspBase extends HttpServlet implements HttpJspPage {
}
@Override
- public final void init(ServletConfig config)
- throws ServletException
- {
+ public final void init(ServletConfig config) throws ServletException {
super.init(config);
jspInit();
_jspInit();
@@ -62,8 +60,7 @@ public abstract class HttpJspBase extends HttpServlet implements HttpJspPage {
@Override
public final void service(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
+ throws ServletException, IOException {
_jspService(request, response);
}
@@ -82,7 +79,6 @@ public abstract class HttpJspBase extends HttpServlet implements HttpJspPage {
}
@Override
- public abstract void _jspService(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException;
+ public abstract void _jspService(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException;
}
diff --git a/java/org/apache/jasper/runtime/JspApplicationContextImpl.java b/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
index c4cf3187e2..deffeaf10e 100644
--- a/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
+++ b/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
@@ -45,8 +45,7 @@ public class JspApplicationContextImpl implements JspApplicationContext {
private static final String KEY = JspApplicationContextImpl.class.getName();
- private final ExpressionFactory expressionFactory =
- ExpressionFactory.newInstance();
+ private final ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
private final List<ELContextListener> contextListeners = new ArrayList<>();
@@ -72,8 +71,7 @@ public class JspApplicationContextImpl implements JspApplicationContext {
if (context == null) {
throw new IllegalArgumentException(Localizer.getMessage("jsp.error.nullArgument"));
}
- JspApplicationContextImpl impl = (JspApplicationContextImpl) context
- .getAttribute(KEY);
+ JspApplicationContextImpl impl = (JspApplicationContextImpl) context.getAttribute(KEY);
if (impl == null) {
impl = new JspApplicationContextImpl();
context.setAttribute(KEY, impl);
@@ -112,8 +110,7 @@ public class JspApplicationContextImpl implements JspApplicationContext {
private ELResolver createELResolver() {
this.instantiated = true;
if (this.resolver == null) {
- CompositeELResolver r = new JasperELResolver(this.resolvers,
- expressionFactory.getStreamELResolver());
+ CompositeELResolver r = new JasperELResolver(this.resolvers, expressionFactory.getStreamELResolver());
this.resolver = r;
}
return this.resolver;
diff --git a/java/org/apache/jasper/runtime/JspContextWrapper.java b/java/org/apache/jasper/runtime/JspContextWrapper.java
index 6548d38111..93c15f21ee 100644
--- a/java/org/apache/jasper/runtime/JspContextWrapper.java
+++ b/java/org/apache/jasper/runtime/JspContextWrapper.java
@@ -56,12 +56,9 @@ import javax.servlet.jsp.tagext.VariableInfo;
import org.apache.jasper.compiler.Localizer;
/**
- * Implementation of a JSP Context Wrapper.
- *
- * The JSP Context Wrapper is a JspContext created and maintained by a tag
- * handler implementation. It wraps the Invoking JSP Context, that is, the
- * JspContext instance passed to the tag handler by the invoking page via
- * setJspContext().
+ * Implementation of a JSP Context Wrapper. The JSP Context Wrapper is a JspContext created and maintained by a tag
+ * handler implementation. It wraps the Invoking JSP Context, that is, the JspContext instance passed to the tag handler
+ * by the invoking page via setJspContext().
*
* @author Kin-man Chung
* @author Jan Luehe
@@ -75,7 +72,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
// Invoking JSP context
private final PageContext invokingJspCtxt;
- private final transient HashMap<String, Object> pageAttributes;
+ private final transient HashMap<String,Object> pageAttributes;
// ArrayList of NESTED scripting variables
private final ArrayList<String> nestedVars;
@@ -88,7 +85,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
private final Map<String,String> aliases;
- private final HashMap<String, Object> originalNestedVars;
+ private final HashMap<String,Object> originalNestedVars;
private ServletContext servletContext = null;
@@ -96,13 +93,12 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
private final PageContext rootJspCtxt;
- public JspContextWrapper(JspTag jspTag, JspContext jspContext,
- ArrayList<String> nestedVars, ArrayList<String> atBeginVars,
- ArrayList<String> atEndVars, Map<String,String> aliases) {
+ public JspContextWrapper(JspTag jspTag, JspContext jspContext, ArrayList<String> nestedVars,
+ ArrayList<String> atBeginVars, ArrayList<String> atEndVars, Map<String,String> aliases) {
this.jspTag = jspTag;
this.invokingJspCtxt = (PageContext) jspContext;
if (jspContext instanceof JspContextWrapper) {
- rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt;
+ rootJspCtxt = ((JspContextWrapper) jspContext).rootJspCtxt;
} else {
rootJspCtxt = invokingJspCtxt;
}
@@ -121,8 +117,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
@Override
- public void initialize(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL,
+ public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL,
boolean needsSession, int bufferSize, boolean autoFlush)
throws IOException, IllegalStateException, IllegalArgumentException {
}
@@ -131,8 +126,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public Object getAttribute(String name) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
return pageAttributes.get(name);
@@ -142,8 +136,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public Object getAttribute(String name, int scope) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (scope == PAGE_SCOPE) {
@@ -157,8 +150,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public void setAttribute(String name, Object value) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (value != null) {
@@ -172,8 +164,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public void setAttribute(String name, Object value, int scope) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (scope == PAGE_SCOPE) {
@@ -191,8 +182,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public Object findAttribute(String name) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
Object o = pageAttributes.get(name);
@@ -220,8 +210,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public void removeAttribute(String name) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
pageAttributes.remove(name);
@@ -236,8 +225,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public void removeAttribute(String name, int scope) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (scope == PAGE_SCOPE) {
@@ -251,8 +239,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
public int getAttributesScope(String name) {
if (name == null) {
- throw new NullPointerException(Localizer
- .getMessage("jsp.error.attribute.null_name"));
+ throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name"));
}
if (pageAttributes.get(name) != null) {
@@ -320,20 +307,17 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
@Override
- public void forward(String relativeUrlPath) throws ServletException,
- IOException {
+ public void forward(String relativeUrlPath) throws ServletException, IOException {
invokingJspCtxt.forward(relativeUrlPath);
}
@Override
- public void include(String relativeUrlPath) throws ServletException,
- IOException {
+ public void include(String relativeUrlPath) throws ServletException, IOException {
invokingJspCtxt.include(relativeUrlPath);
}
@Override
- public void include(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
+ public void include(String relativeUrlPath, boolean flush) throws ServletException, IOException {
invokingJspCtxt.include(relativeUrlPath, false);
}
@@ -365,16 +349,14 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
@Override
- public void handlePageException(Exception ex) throws IOException,
- ServletException {
+ public void handlePageException(Exception ex) throws IOException, ServletException {
// Should never be called since handleException() called with a
// Throwable in the generated servlet.
handlePageException((Throwable) ex);
}
@Override
- public void handlePageException(Throwable t) throws IOException,
- ServletException {
+ public void handlePageException(Throwable t) throws IOException, ServletException {
invokingJspCtxt.handlePageException(t);
}
@@ -413,31 +395,30 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
/**
- * Copies the variables of the given scope from the virtual page scope of
- * this JSP context wrapper to the page scope of the invoking JSP context.
+ * Copies the variables of the given scope from the virtual page scope of this JSP context wrapper to the page scope
+ * of the invoking JSP context.
*
- * @param scope
- * variable scope (one of NESTED, AT_BEGIN, or AT_END)
+ * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
*/
private void copyTagToPageScope(int scope) {
Iterator<String> iter = null;
switch (scope) {
- case VariableInfo.NESTED:
- if (nestedVars != null) {
- iter = nestedVars.iterator();
- }
- break;
- case VariableInfo.AT_BEGIN:
- if (atBeginVars != null) {
- iter = atBeginVars.iterator();
- }
- break;
- case VariableInfo.AT_END:
- if (atEndVars != null) {
- iter = atEndVars.iterator();
- }
- break;
+ case VariableInfo.NESTED:
+ if (nestedVars != null) {
+ iter = nestedVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_BEGIN:
+ if (atBeginVars != null) {
+ iter = atBeginVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_END:
+ if (atEndVars != null) {
+ iter = atEndVars.iterator();
+ }
+ break;
}
while ((iter != null) && iter.hasNext()) {
@@ -453,8 +434,8 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
/**
- * Saves the values of any NESTED variables that are present in the invoking
- * JSP context, so they can later be restored.
+ * Saves the values of any NESTED variables that are present in the invoking JSP context, so they can later be
+ * restored.
*/
private void saveNestedVariables() {
if (nestedVars != null) {
@@ -486,13 +467,12 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
/**
- * Checks to see if the given variable name is used as an alias, and if so,
- * returns the variable name for which it is used as an alias.
+ * Checks to see if the given variable name is used as an alias, and if so, returns the variable name for which it
+ * is used as an alias.
+ *
+ * @param varName The variable name to check
*
- * @param varName
- * The variable name to check
- * @return The variable name for which varName is used as an alias, or
- * varName if it is not being used as an alias
+ * @return The variable name for which varName is used as an alias, or varName if it is not being used as an alias
*/
private String findAlias(String varName) {
@@ -637,7 +617,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
}
@Override
- public void enterLambdaScope(Map<String, Object> arguments) {
+ public void enterLambdaScope(Map<String,Object> arguments) {
wrapped.enterLambdaScope(arguments);
}
diff --git a/java/org/apache/jasper/runtime/JspFactoryImpl.java b/java/org/apache/jasper/runtime/JspFactoryImpl.java
index efef3ecf19..daeb3e710f 100644
--- a/java/org/apache/jasper/runtime/JspFactoryImpl.java
+++ b/java/org/apache/jasper/runtime/JspFactoryImpl.java
@@ -39,37 +39,33 @@ import org.apache.jasper.Constants;
public class JspFactoryImpl extends JspFactory {
private static final boolean USE_POOL =
- Boolean.parseBoolean(System.getProperty("org.apache.jasper.runtime.JspFactoryImpl.USE_POOL", "true"));
+ Boolean.parseBoolean(System.getProperty("org.apache.jasper.runtime.JspFactoryImpl.USE_POOL", "true"));
private static final int POOL_SIZE =
- Integer.parseInt(System.getProperty("org.apache.jasper.runtime.JspFactoryImpl.POOL_SIZE", "8"));
+ Integer.parseInt(System.getProperty("org.apache.jasper.runtime.JspFactoryImpl.POOL_SIZE", "8"));
private final ThreadLocal<PageContextPool> localPool = new ThreadLocal<>();
@Override
- public PageContext getPageContext(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL, boolean needsSession,
- int bufferSize, boolean autoflush) {
+ public PageContext getPageContext(Servlet servlet, ServletRequest request, ServletResponse response,
+ String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
- if( Constants.IS_SECURITY_ENABLED ) {
- PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
- this, servlet, request, response, errorPageURL,
+ if (Constants.IS_SECURITY_ENABLED) {
+ PrivilegedGetPageContext dp = new PrivilegedGetPageContext(this, servlet, request, response, errorPageURL,
needsSession, bufferSize, autoflush);
return AccessController.doPrivileged(dp);
} else {
- return internalGetPageContext(servlet, request, response,
- errorPageURL, needsSession,
- bufferSize, autoflush);
+ return internalGetPageContext(servlet, request, response, errorPageURL, needsSession, bufferSize,
+ autoflush);
}
}
@Override
public void releasePageContext(PageContext pc) {
- if( pc == null ) {
+ if (pc == null) {
return;
}
- if( Constants.IS_SECURITY_ENABLED ) {
- PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
- this,pc);
+ if (Constants.IS_SECURITY_ENABLED) {
+ PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(this, pc);
AccessController.doPrivileged(dp);
} else {
internalReleasePageContext(pc);
@@ -86,9 +82,8 @@ public class JspFactoryImpl extends JspFactory {
};
}
- private PageContext internalGetPageContext(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL, boolean needsSession,
- int bufferSize, boolean autoflush) {
+ private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response,
+ String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
PageContext pc;
if (USE_POOL) {
@@ -106,8 +101,7 @@ public class JspFactoryImpl extends JspFactory {
}
try {
- pc.initialize(servlet, request, response, errorPageURL,
- needsSession, bufferSize, autoflush);
+ pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush);
} catch (IOException ioe) {
// Implementation never throws IOE but can't change the signature
// since it is part of the JSP API
@@ -123,8 +117,7 @@ public class JspFactoryImpl extends JspFactory {
}
}
- private static class PrivilegedGetPageContext
- implements PrivilegedAction<PageContext> {
+ private static class PrivilegedGetPageContext implements PrivilegedAction<PageContext> {
private JspFactoryImpl factory;
private Servlet servlet;
@@ -135,9 +128,9 @@ public class JspFactoryImpl extends JspFactory {
private int bufferSize;
private boolean autoflush;
- PrivilegedGetPageContext(JspFactoryImpl factory, Servlet servlet,
- ServletRequest request, ServletResponse response, String errorPageURL,
- boolean needsSession, int bufferSize, boolean autoflush) {
+ PrivilegedGetPageContext(JspFactoryImpl factory, Servlet servlet, ServletRequest request,
+ ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize,
+ boolean autoflush) {
this.factory = factory;
this.servlet = servlet;
this.request = request;
@@ -150,19 +143,17 @@ public class JspFactoryImpl extends JspFactory {
@Override
public PageContext run() {
- return factory.internalGetPageContext(servlet, request, response,
- errorPageURL, needsSession, bufferSize, autoflush);
+ return factory.internalGetPageContext(servlet, request, response, errorPageURL, needsSession, bufferSize,
+ autoflush);
}
}
- private static class PrivilegedReleasePageContext
- implements PrivilegedAction<Void> {
+ private static class PrivilegedReleasePageContext implements PrivilegedAction<Void> {
private JspFactoryImpl factory;
private PageContext pageContext;
- PrivilegedReleasePageContext(JspFactoryImpl factory,
- PageContext pageContext) {
+ PrivilegedReleasePageContext(JspFactoryImpl factory, PageContext pageContext) {
this.factory = factory;
this.pageContext = pageContext;
}
@@ -174,7 +165,7 @@ public class JspFactoryImpl extends JspFactory {
}
}
- private static final class PageContextPool {
+ private static final class PageContextPool {
private final PageContext[] pool;
@@ -203,8 +194,7 @@ public class JspFactoryImpl extends JspFactory {
}
@Override
- public JspApplicationContext getJspApplicationContext(
- final ServletContext context) {
+ public JspApplicationContext getJspApplicationContext(final ServletContext context) {
if (Constants.IS_SECURITY_ENABLED) {
return AccessController.doPrivileged(
(PrivilegedAction<JspApplicationContext>) () -> JspApplicationContextImpl.getInstance(context));
diff --git a/java/org/apache/jasper/runtime/JspFragmentHelper.java b/java/org/apache/jasper/runtime/JspFragmentHelper.java
index ee6c81784c..543e3d3ae9 100644
--- a/java/org/apache/jasper/runtime/JspFragmentHelper.java
+++ b/java/org/apache/jasper/runtime/JspFragmentHelper.java
@@ -22,13 +22,11 @@ import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.JspTag;
/**
- * Helper class from which all Jsp Fragment helper classes extend.
- * This class allows for the emulation of numerous fragments within
- * a single class, which in turn reduces the load on the class loader
- * since there are potentially many JspFragments in a single page.
+ * Helper class from which all Jsp Fragment helper classes extend. This class allows for the emulation of numerous
+ * fragments within a single class, which in turn reduces the load on the class loader since there are potentially many
+ * JspFragments in a single page.
* <p>
- * The class also provides various utility methods for JspFragment
- * implementations.
+ * The class also provides various utility methods for JspFragment implementations.
*
* @author Mark Roth
*/
@@ -39,13 +37,11 @@ public abstract class JspFragmentHelper extends JspFragment {
protected final PageContext _jspx_page_context;
protected final JspTag parentTag;
- public JspFragmentHelper( int discriminator, JspContext jspContext,
- JspTag parentTag )
- {
+ public JspFragmentHelper(int discriminator, JspContext jspContext, JspTag parentTag) {
this.discriminator = discriminator;
this.jspContext = jspContext;
- if(jspContext instanceof PageContext) {
- _jspx_page_context = (PageContext)jspContext;
+ if (jspContext instanceof PageContext) {
+ _jspx_page_context = (PageContext) jspContext;
} else {
_jspx_page_context = null;
}
diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
index 559e5366ca..6898e0b93c 100644
--- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
+++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
@@ -43,8 +43,7 @@ import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.InstanceManager;
/**
- * Bunch of util methods that are used by code generated for useBean,
- * getProperty and setProperty.
+ * Bunch of util methods that are used by code generated for useBean, getProperty and setProperty.
*
* @author Mandar Raje
* @author Shawn Bayern
@@ -68,28 +67,24 @@ public class JspRuntimeLibrary {
}
/**
- * Returns the value of the javax.servlet.error.exception request
- * attribute value, if present, otherwise the value of the
- * javax.servlet.jsp.jspException request attribute value.
+ * Returns the value of the javax.servlet.error.exception request attribute value, if present, otherwise the value
+ * of the javax.servlet.jsp.jspException request attribute value. This method is called at the beginning of the
+ * generated servlet code for a JSP error page, when the "exception" implicit scripting language variable is
+ * initialized.
*
- * This method is called at the beginning of the generated servlet code
- * for a JSP error page, when the "exception" implicit scripting language
- * variable is initialized.
* @param request The Servlet request
+ *
* @return the throwable in the error attribute if any
*/
public static Throwable getThrowable(ServletRequest request) {
- Throwable error = (Throwable) request.getAttribute(
- RequestDispatcher.ERROR_EXCEPTION);
+ Throwable error = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
if (error == null) {
error = (Throwable) request.getAttribute(PageContext.EXCEPTION);
if (error != null) {
/*
- * The only place that sets JSP_EXCEPTION is
- * PageContextImpl.handlePageException(). It really should set
- * SERVLET_EXCEPTION, but that would interfere with the
- * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we
- * need to set SERVLET_EXCEPTION.
+ * The only place that sets JSP_EXCEPTION is PageContextImpl.handlePageException(). It really should set
+ * SERVLET_EXCEPTION, but that would interfere with the ErrorReportValve. Therefore, if JSP_EXCEPTION is
+ * set, we need to set SERVLET_EXCEPTION.
*/
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, error);
}
@@ -221,10 +216,8 @@ public class JspRuntimeLibrary {
}
- public static Object convert(String propertyName, String s, Class<?> t,
- Class<?> propertyEditorClass)
- throws JasperException
- {
+ public static Object convert(String propertyName, String s, Class<?> t, Class<?> propertyEditorClass)
+ throws JasperException {
try {
if (s == null) {
if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) {
@@ -234,13 +227,12 @@ public class JspRuntimeLibrary {
}
}
if (propertyEditorClass != null) {
- return getValueFromBeanInfoPropertyEditor(
- t, propertyName, s, propertyEditorClass);
+ return getValueFromBeanInfoPropertyEditor(t, propertyName, s, propertyEditorClass);
} else if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) {
return Boolean.valueOf(s);
} else if (t.equals(Byte.class) || t.equals(Byte.TYPE)) {
if (s.length() == 0) {
- return Byte.valueOf((byte)0);
+ return Byte.valueOf((byte) 0);
} else {
return Byte.valueOf(s);
}
@@ -280,13 +272,12 @@ public class JspRuntimeLibrary {
} else {
return Short.valueOf(s);
}
- } else if ( t.equals(String.class) ) {
+ } else if (t.equals(String.class)) {
return s;
} else if (t.getName().equals("java.lang.Object")) {
return new String(s);
} else {
- return getValueFromPropertyEditorManager(
- t, propertyName, s);
+ return getValueFromPropertyEditorManager(t, propertyName, s);
}
} catch (Exception ex) {
throw new JasperException(ex);
@@ -294,22 +285,18 @@ public class JspRuntimeLibrary {
}
- public static void introspect(Object bean, ServletRequest request)
- throws JasperException
- {
+ public static void introspect(Object bean, ServletRequest request) throws JasperException {
Enumeration<String> e = request.getParameterNames();
- while ( e.hasMoreElements() ) {
- String name = e.nextElement();
+ while (e.hasMoreElements()) {
+ String name = e.nextElement();
String value = request.getParameter(name);
introspecthelper(bean, name, value, request, name, true);
}
}
- public static void introspecthelper(Object bean, String prop,
- String value, ServletRequest request,
- String param, boolean ignoreMethodNF)
- throws JasperException {
+ public static void introspecthelper(Object bean, String prop, String value, ServletRequest request, String param,
+ boolean ignoreMethodNF) throws JasperException {
Method method = null;
Class<?> type = null;
Class<?> propertyEditorClass = null;
@@ -320,11 +307,9 @@ public class JspRuntimeLibrary {
type = method.getParameterTypes()[0];
}
} else {
- java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(bean.getClass());
- if ( info != null ) {
- java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
+ java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(bean.getClass());
+ if (info != null) {
+ java.beans.PropertyDescriptor pd[] = info.getPropertyDescriptors();
for (java.beans.PropertyDescriptor propertyDescriptor : pd) {
if (propertyDescriptor.getName().equals(prop)) {
method = propertyDescriptor.getWriteMethod();
@@ -338,27 +323,25 @@ public class JspRuntimeLibrary {
if (method != null && type != null) {
if (type.isArray()) {
if (request == null) {
- throw new JasperException(
- Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
}
Class<?> t = type.getComponentType();
String[] values = request.getParameterValues(param);
- //XXX Please check.
- if(values == null) {
+ // XXX Please check.
+ if (values == null) {
return;
}
- if(t.equals(String.class)) {
+ if (t.equals(String.class)) {
method.invoke(bean, new Object[] { values });
} else {
- createTypedArray (prop, bean, method, values, t,
- propertyEditorClass);
+ createTypedArray(prop, bean, method, values, t, propertyEditorClass);
}
} else {
- if(value == null || (param != null && value.equals(""))) {
+ if (value == null || (param != null && value.equals(""))) {
return;
}
Object oval = convert(prop, value, type, propertyEditorClass);
- if ( oval != null ) {
+ if (oval != null) {
method.invoke(bean, new Object[] { oval });
}
}
@@ -371,23 +354,18 @@ public class JspRuntimeLibrary {
if (!ignoreMethodNF && (method == null)) {
if (type == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.noproperty",
- prop,
- bean.getClass().getName()));
+ Localizer.getMessage("jsp.error.beans.noproperty", prop, bean.getClass().getName()));
} else {
- throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
- prop,
- type.getName(),
- bean.getClass().getName()));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.nomethod.setproperty", prop,
+ type.getName(), bean.getClass().getName()));
}
}
}
- //-------------------------------------------------------------------
+ // -------------------------------------------------------------------
// functions to convert builtin Java data types to string.
- //-------------------------------------------------------------------
+ // -------------------------------------------------------------------
public static String toString(Object o) {
return String.valueOf(o);
}
@@ -426,148 +404,143 @@ public class JspRuntimeLibrary {
/**
- * Create a typed array.
- * This is a special case where params are passed through
- * the request and the property is indexed.
- * @param propertyName The property name
- * @param bean The bean
- * @param method The method
- * @param values Array values
- * @param t The class
+ * Create a typed array. This is a special case where params are passed through the request and the property is
+ * indexed.
+ *
+ * @param propertyName The property name
+ * @param bean The bean
+ * @param method The method
+ * @param values Array values
+ * @param t The class
* @param propertyEditorClass The editor for the property
+ *
* @throws JasperException An error occurred
*/
- public static void createTypedArray(String propertyName,
- Object bean,
- Method method,
- String[] values,
- Class<?> t,
- Class<?> propertyEditorClass)
- throws JasperException {
+ public static void createTypedArray(String propertyName, Object bean, Method method, String[] values, Class<?> t,
+ Class<?> propertyEditorClass) throws JasperException {
try {
if (propertyEditorClass != null) {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
- tmpval[i] = getValueFromBeanInfoPropertyEditor(
- t, propertyName, values[i], propertyEditorClass);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = getValueFromBeanInfoPropertyEditor(t, propertyName, values[i], propertyEditorClass);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Integer.class)) {
- Integer []tmpval = new Integer[values.length];
- for (int i = 0 ; i < values.length; i++) {
- tmpval[i] = Integer.valueOf(values[i]);
+ Integer[] tmpval = new Integer[values.length];
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = Integer.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Byte.class)) {
Byte[] tmpval = new Byte[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Byte.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Boolean.class)) {
Boolean[] tmpval = new Boolean[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Boolean.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Short.class)) {
Short[] tmpval = new Short[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Short.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Long.class)) {
Long[] tmpval = new Long[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Long.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Double.class)) {
Double[] tmpval = new Double[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Double.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Float.class)) {
Float[] tmpval = new Float[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Float.valueOf(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(Character.class)) {
Character[] tmpval = new Character[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Character.valueOf(values[i].charAt(0));
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(int.class)) {
- int []tmpval = new int[values.length];
- for (int i = 0 ; i < values.length; i++) {
- tmpval[i] = Integer.parseInt (values[i]);
+ int[] tmpval = new int[values.length];
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = Integer.parseInt(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(byte.class)) {
byte[] tmpval = new byte[values.length];
- for (int i = 0 ; i < values.length; i++) {
- tmpval[i] = Byte.parseByte (values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = Byte.parseByte(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(boolean.class)) {
boolean[] tmpval = new boolean[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Boolean.parseBoolean(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(short.class)) {
short[] tmpval = new short[values.length];
- for (int i = 0 ; i < values.length; i++) {
- tmpval[i] = Short.parseShort (values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = Short.parseShort(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(long.class)) {
long[] tmpval = new long[values.length];
- for (int i = 0 ; i < values.length; i++) {
- tmpval[i] = Long.parseLong (values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = Long.parseLong(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(double.class)) {
double[] tmpval = new double[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Double.parseDouble(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(float.class)) {
float[] tmpval = new float[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = Float.parseFloat(values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else if (t.equals(char.class)) {
char[] tmpval = new char[values.length];
- for (int i = 0 ; i < values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = values[i].charAt(0);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
} else {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
- tmpval[i] =
- getValueFromPropertyEditorManager(
- t, propertyName, values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] = getValueFromPropertyEditorManager(t, propertyName, values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[] { tmpval });
}
} catch (RuntimeException | ReflectiveOperationException ex) {
Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
ExceptionUtils.handleThrowable(thr);
- throw new JasperException ("error in invoking method", ex);
+ throw new JasperException("error in invoking method", ex);
}
}
/**
* Escape special shell characters.
+ *
* @param unescString The string to shell-escape
+ *
* @return The escaped shell string.
*/
public static String escapeQueryString(String unescString) {
@@ -591,11 +564,9 @@ public class JspRuntimeLibrary {
}
- public static Object handleGetProperty(Object o, String prop)
- throws JasperException {
+ public static Object handleGetProperty(Object o, String prop) throws JasperException {
if (o == null) {
- throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nullbean"));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.nullbean"));
}
Object value = null;
try {
@@ -604,26 +575,18 @@ public class JspRuntimeLibrary {
} catch (Exception ex) {
Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
ExceptionUtils.handleThrowable(thr);
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
return value;
}
// handles <jsp:setProperty> with EL expression for 'value' attribute
- public static void handleSetPropertyExpression(Object bean,
- String prop, String expression, PageContext pageContext,
- ProtectedFunctionMapper functionMapper )
- throws JasperException
- {
+ public static void handleSetPropertyExpression(Object bean, String prop, String expression, PageContext pageContext,
+ ProtectedFunctionMapper functionMapper) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] {
- PageContextImpl.proprietaryEvaluate(
- expression,
- method.getParameterTypes()[0],
- pageContext,
- functionMapper)
- });
+ method.invoke(bean, new Object[] { PageContextImpl.proprietaryEvaluate(expression,
+ method.getParameterTypes()[0], pageContext, functionMapper) });
} catch (Exception ex) {
Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
ExceptionUtils.handleThrowable(thr);
@@ -631,10 +594,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- Object value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, Object value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { value });
@@ -645,10 +605,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- int value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, int value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Integer.valueOf(value) });
@@ -659,10 +616,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- short value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, short value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Short.valueOf(value) });
@@ -673,10 +627,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- long value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, long value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Long.valueOf(value) });
@@ -687,10 +638,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- double value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, double value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Double.valueOf(value) });
@@ -701,10 +649,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- float value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, float value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Float.valueOf(value) });
@@ -715,10 +660,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- char value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, char value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Character.valueOf(value) });
@@ -729,10 +671,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- byte value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, byte value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Byte.valueOf(value) });
@@ -743,10 +682,7 @@ public class JspRuntimeLibrary {
}
}
- public static void handleSetProperty(Object bean, String prop,
- boolean value)
- throws JasperException
- {
+ public static void handleSetProperty(Object bean, String prop, boolean value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Boolean.valueOf(value) });
@@ -759,7 +695,9 @@ public class JspRuntimeLibrary {
/**
* Reverse of Introspector.decapitalize.
+ *
* @param name The name
+ *
* @return the capitalized string
*/
public static String capitalize(String name) {
@@ -771,8 +709,7 @@ public class JspRuntimeLibrary {
return new String(chars);
}
- public static Method getWriteMethod(Class<?> beanClass, String prop)
- throws JasperException {
+ public static Method getWriteMethod(Class<?> beanClass, String prop) throws JasperException {
Method result = null;
Class<?> type = null;
if (GRAAL) {
@@ -795,24 +732,22 @@ public class JspRuntimeLibrary {
}
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
}
if (result == null) {
if (type == null) {
- throw new JasperException(Localizer.getMessage(
- "jsp.error.beans.noproperty", prop, beanClass.getName()));
+ throw new JasperException(
+ Localizer.getMessage("jsp.error.beans.noproperty", prop, beanClass.getName()));
} else {
- throw new JasperException(Localizer.getMessage(
- "jsp.error.beans.nomethod.setproperty",
- prop, type.getName(), beanClass.getName()));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.nomethod.setproperty", prop,
+ type.getName(), beanClass.getName()));
}
}
return result;
}
- public static Method getReadMethod(Class<?> beanClass, String prop)
- throws JasperException {
+ public static Method getReadMethod(Class<?> beanClass, String prop) throws JasperException {
Method result = null;
Class<?> type = null;
if (GRAAL) {
@@ -835,52 +770,43 @@ public class JspRuntimeLibrary {
}
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
}
if (result == null) {
if (type == null) {
- throw new JasperException(Localizer.getMessage(
- "jsp.error.beans.noproperty", prop, beanClass.getName()));
+ throw new JasperException(
+ Localizer.getMessage("jsp.error.beans.noproperty", prop, beanClass.getName()));
} else {
- throw new JasperException(Localizer.getMessage(
- "jsp.error.beans.nomethod", prop, beanClass.getName()));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.nomethod", prop, beanClass.getName()));
}
}
return result;
}
- //*********************************************************************
+ // *********************************************************************
// PropertyEditor Support
- public static Object getValueFromBeanInfoPropertyEditor(
- Class<?> attrClass, String attrName, String attrValue,
- Class<?> propertyEditorClass)
- throws JasperException
- {
+ public static Object getValueFromBeanInfoPropertyEditor(Class<?> attrClass, String attrName, String attrValue,
+ Class<?> propertyEditorClass) throws JasperException {
try {
- PropertyEditor pe = (PropertyEditor)propertyEditorClass.getConstructor().newInstance();
+ PropertyEditor pe = (PropertyEditor) propertyEditorClass.getConstructor().newInstance();
pe.setAsText(attrValue);
return pe.getValue();
} catch (Exception ex) {
if (attrValue.length() == 0) {
return null;
} else {
- throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
+ attrClass.getName(), attrName, ex.getMessage()));
}
}
}
- public static Object getValueFromPropertyEditorManager(
- Class<?> attrClass, String attrName, String attrValue)
- throws JasperException
- {
+ public static Object getValueFromPropertyEditorManager(Class<?> attrClass, String attrName, String attrValue)
+ throws JasperException {
try {
- PropertyEditor propEditor =
- PropertyEditorManager.findEditor(attrClass);
+ PropertyEditor propEditor = PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
@@ -888,16 +814,14 @@ public class JspRuntimeLibrary {
return null;
} else {
throw new IllegalArgumentException(
- Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
+ Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
if (attrValue.length() == 0) {
return null;
} else {
- throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
+ attrClass.getName(), attrName, ex.getMessage()));
}
}
}
@@ -909,15 +833,14 @@ public class JspRuntimeLibrary {
/**
- * Convert a possibly relative resource path into a context-relative
- * resource path that starts with a '/'.
+ * Convert a possibly relative resource path into a context-relative resource path that starts with a '/'.
*
- * @param request The servlet request we are processing
+ * @param request The servlet request we are processing
* @param relativePath The possibly relative resource path
+ *
* @return an absolute path
*/
- public static String getContextRelativePath(ServletRequest request,
- String relativePath) {
+ public static String getContextRelativePath(ServletRequest request, String relativePath) {
if (relativePath.startsWith("/")) {
return relativePath;
@@ -926,11 +849,9 @@ public class JspRuntimeLibrary {
return relativePath;
}
HttpServletRequest hrequest = (HttpServletRequest) request;
- String uri = (String) request.getAttribute(
- RequestDispatcher.INCLUDE_SERVLET_PATH);
+ String uri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
if (uri != null) {
- String pathInfo = (String)
- request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
+ String pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
if (pathInfo == null) {
if (uri.lastIndexOf('/') >= 0) {
uri = uri.substring(0, uri.lastIndexOf('/'));
@@ -948,24 +869,19 @@ public class JspRuntimeLibrary {
/**
- * Perform a RequestDispatcher.include() operation, with optional flushing
- * of the response beforehand.
+ * Perform a RequestDispatcher.include() operation, with optional flushing of the response beforehand.
*
- * @param request The servlet request we are processing
- * @param response The servlet response we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are processing
* @param relativePath The relative path of the resource to be included
- * @param out The Writer to whom we are currently writing
- * @param flush Should we flush before the include is processed?
+ * @param out The Writer to whom we are currently writing
+ * @param flush Should we flush before the include is processed?
*
- * @exception IOException if thrown by the included servlet
+ * @exception IOException if thrown by the included servlet
* @exception ServletException if thrown by the included servlet
*/
- public static void include(ServletRequest request,
- ServletResponse response,
- String relativePath,
- JspWriter out,
- boolean flush)
- throws IOException, ServletException {
+ public static void include(ServletRequest request, ServletResponse response, String relativePath, JspWriter out,
+ boolean flush) throws IOException, ServletException {
if (flush && !(out instanceof BodyContent)) {
out.flush();
@@ -974,26 +890,26 @@ public class JspRuntimeLibrary {
// FIXME - It is tempting to use request.getRequestDispatcher() to
// resolve a relative path directly, but Catalina currently does not
// take into account whether the caller is inside a RequestDispatcher
- // include or not. Whether Catalina *should* take that into account
- // is a spec issue currently under review. In the mean time,
+ // include or not. Whether Catalina *should* take that into account
+ // is a spec issue currently under review. In the mean time,
// replicate Jasper's previous behavior
String resourcePath = getContextRelativePath(request, relativePath);
RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
if (rd != null) {
- rd.include(request,
- new ServletResponseWrapperInclude(response, out));
+ rd.include(request, new ServletResponseWrapperInclude(response, out));
} else {
- throw new JasperException(
- Localizer.getMessage("jsp.error.include.exception", resourcePath));
+ throw new JasperException(Localizer.getMessage("jsp.error.include.exception", resourcePath));
}
}
/**
* URL encodes a string, based on the supplied character encoding.
- * @param s The String to be URL encoded.
+ *
+ * @param s The String to be URL encoded.
* @param enc The character encoding
+ *
* @return The URL encoded String
*/
public static String URLEncode(String s, String enc) {
@@ -1001,7 +917,7 @@ public class JspRuntimeLibrary {
return "null";
}
if (enc == null) {
- enc = "ISO-8859-1"; // The default request encoding
+ enc = "ISO-8859-1"; // The default request encoding
}
String result = null;
@@ -1019,8 +935,7 @@ public class JspRuntimeLibrary {
}
- public static JspWriter startBufferedBody(PageContext pageContext, BodyTag tag)
- throws JspException {
+ public static JspWriter startBufferedBody(PageContext pageContext, BodyTag tag) throws JspException {
BodyContent out = pageContext.pushBody();
tag.setBodyContent(out);
tag.doInitBody();
diff --git a/java/org/apache/jasper/runtime/JspSourceDependent.java b/java/org/apache/jasper/runtime/JspSourceDependent.java
index f6d9fa093a..bc863e5405 100644
--- a/java/org/apache/jasper/runtime/JspSourceDependent.java
+++ b/java/org/apache/jasper/runtime/JspSourceDependent.java
@@ -19,8 +19,8 @@ package org.apache.jasper.runtime;
import java.util.Map;
/**
- * Interface for tracking the source files dependencies, for the purpose
- * of compiling out of date pages. This is used for:
+ * Interface for tracking the source files dependencies, for the purpose of compiling out of date pages. This is used
+ * for:
* <ul>
* <li>files that are included by page directives</li>
* <li>files that are included by include-prelude and include-coda in jsp:config</li>
@@ -31,10 +31,10 @@ import java.util.Map;
public interface JspSourceDependent {
- /**
- * Returns a map of file names and last modified time where the current page
- * has a source dependency on the file.
- * @return the map of dependent resources
- */
+ /**
+ * Returns a map of file names and last modified time where the current page has a source dependency on the file.
+ *
+ * @return the map of dependent resources
+ */
Map<String,Long> getDependants();
}
\ No newline at end of file
diff --git a/java/org/apache/jasper/runtime/JspSourceImports.java b/java/org/apache/jasper/runtime/JspSourceImports.java
index 09f58d822b..d65e8bd757 100644
--- a/java/org/apache/jasper/runtime/JspSourceImports.java
+++ b/java/org/apache/jasper/runtime/JspSourceImports.java
@@ -19,12 +19,12 @@ package org.apache.jasper.runtime;
import java.util.Set;
/**
- * The EL engine needs access to the imports used in the JSP page to configure
- * the ELContext. The imports are available at compile time but the ELContext
- * is created lazily per page. This interface exposes the imports at runtime so
- * that they may be added to the ELContext when it is created.
+ * The EL engine needs access to the imports used in the JSP page to configure the ELContext. The imports are available
+ * at compile time but the ELContext is created lazily per page. This interface exposes the imports at runtime so that
+ * they may be added to the ELContext when it is created.
*/
public interface JspSourceImports {
Set<String> getPackageImports();
+
Set<String> getClassImports();
}
diff --git a/java/org/apache/jasper/runtime/JspWriterImpl.java b/java/org/apache/jasper/runtime/JspWriterImpl.java
index c29d06616b..ca53a18b7f 100644
--- a/java/org/apache/jasper/runtime/JspWriterImpl.java
+++ b/java/org/apache/jasper/runtime/JspWriterImpl.java
@@ -27,15 +27,9 @@ import org.apache.jasper.Constants;
import org.apache.jasper.compiler.Localizer;
/**
- * Write text to a character-output stream, buffering characters so as
- * to provide for the efficient writing of single characters, arrays,
- * and strings.
- *
- * Provide support for discarding for the output that has been
- * buffered.
- *
- * This needs revisiting when the buffering problems in the JSP spec
- * are fixed -akv
+ * Write text to a character-output stream, buffering characters so as to provide for the efficient writing of single
+ * characters, arrays, and strings. Provide support for discarding for the output that has been buffered. This needs
+ * revisiting when the buffering problems in the JSP spec are fixed -akv
*
* @author Anil K. Vijendran
*/
@@ -49,21 +43,20 @@ public class JspWriterImpl extends JspWriter {
private boolean closed = false;
public JspWriterImpl() {
- super( Constants.DEFAULT_BUFFER_SIZE, true );
+ super(Constants.DEFAULT_BUFFER_SIZE, true);
}
/**
- * Create a new buffered character-output stream that uses an output
- * buffer of the given size.
+ * Create a new buffered character-output stream that uses an output buffer of the given size.
+ *
+ * @param response A Servlet Response
+ * @param sz Output-buffer size, a positive integer
+ * @param autoFlush <code>true</code> to automatically flush on buffer full, <code>false</code> to throw an overflow
+ * exception in that case
*
- * @param response A Servlet Response
- * @param sz Output-buffer size, a positive integer
- * @param autoFlush <code>true</code> to automatically flush on buffer
- * full, <code>false</code> to throw an overflow exception in that case
- * @exception IllegalArgumentException If sz is <= 0
+ * @exception IllegalArgumentException If sz is <= 0
*/
- public JspWriterImpl(ServletResponse response, int sz,
- boolean autoFlush) {
+ public JspWriterImpl(ServletResponse response, int sz, boolean autoFlush) {
super(sz, autoFlush);
if (sz < 0) {
throw new IllegalArgumentException(Localizer.getMessage("jsp.error.negativeBufferSize"));
@@ -73,14 +66,14 @@ public class JspWriterImpl extends JspWriter {
nextChar = 0;
}
- void init( ServletResponse response, int sz, boolean autoFlush ) {
- this.response= response;
- if( sz > 0 && ( cb == null || sz > cb.length ) ) {
- cb=new char[sz];
+ void init(ServletResponse response, int sz, boolean autoFlush) {
+ this.response = response;
+ if (sz > 0 && (cb == null || sz > cb.length)) {
+ cb = new char[sz];
}
nextChar = 0;
- this.autoFlush=autoFlush;
- this.bufferSize=sz;
+ this.autoFlush = autoFlush;
+ this.bufferSize = sz;
}
/**
@@ -95,9 +88,9 @@ public class JspWriterImpl extends JspWriter {
}
/**
- * Flush the output buffer to the underlying character stream, without
- * flushing the stream itself. This method is non-private only so that it
- * may be invoked by PrintStream.
+ * Flush the output buffer to the underlying character stream, without flushing the stream itself. This method is
+ * non-private only so that it may be invoked by PrintStream.
+ *
* @throws IOException Error writing buffered data
*/
protected final void flushBuffer() throws IOException {
@@ -133,12 +126,10 @@ public class JspWriterImpl extends JspWriter {
public final void clear() throws IOException {
if ((bufferSize == 0) && (out != null)) {
// clear() is illegal after any unbuffered output (JSP.5.5)
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.ise_on_clear"));
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.ise_on_clear"));
}
if (flushed) {
- throw new IOException(
- Localizer.getMessage("jsp.error.attempt_to_clear_flushed_buffer"));
+ throw new IOException(Localizer.getMessage("jsp.error.attempt_to_clear_flushed_buffer"));
}
ensureOpen();
nextChar = 0;
@@ -147,8 +138,7 @@ public class JspWriterImpl extends JspWriter {
@Override
public void clearBuffer() throws IOException {
if (bufferSize == 0) {
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.ise_on_clear"));
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.ise_on_clear"));
}
ensureOpen();
nextChar = 0;
@@ -159,7 +149,7 @@ public class JspWriterImpl extends JspWriter {
}
@Override
- public void flush() throws IOException {
+ public void flush() throws IOException {
flushBuffer();
if (out != null) {
out.flush();
@@ -212,8 +202,8 @@ public class JspWriterImpl extends JspWriter {
}
/**
- * Our own little min method, to avoid loading java.lang.Math if we've run
- * out of file descriptors and we're trying to print a stack trace.
+ * Our own little min method, to avoid loading java.lang.Math if we've run out of file descriptors and we're trying
+ * to print a stack trace.
*/
private static int min(int a, int b) {
if (a < b) {
@@ -232,17 +222,17 @@ public class JspWriterImpl extends JspWriter {
return;
}
- if ((off < 0) || (off > cbuf.length) || (len < 0) ||
- ((off + len) > cbuf.length) || ((off + len) < 0)) {
+ if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
if (len >= bufferSize) {
- /* If the request length exceeds the size of the output buffer,
- flush the buffer and then write the data directly. In this
- way buffered streams will cascade harmlessly. */
+ /*
+ * If the request length exceeds the size of the output buffer, flush the buffer and then write the data
+ * directly. In this way buffered streams will cascade harmlessly.
+ */
if (autoFlush) {
flushBuffer();
} else {
diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java
index 07416529eb..8724ef4641 100644
--- a/java/org/apache/jasper/runtime/PageContextImpl.java
+++ b/java/org/apache/jasper/runtime/PageContextImpl.java
@@ -51,8 +51,7 @@ import org.apache.jasper.el.ELContextImpl;
import org.apache.jasper.runtime.JspContextWrapper.ELContextWrapper;
/**
- * Implementation of the PageContext class from the JSP spec. Also doubles as a
- * VariableResolver for the EL.
+ * Implementation of the PageContext class from the JSP spec. Also doubles as a VariableResolver for the EL.
*
* @author Anil K. Vijendran
* @author Larry Cable
@@ -84,7 +83,7 @@ public class PageContextImpl extends PageContext {
private String errorPageURL;
// page-scope attributes
- private final transient HashMap<String, Object> attributes;
+ private final transient HashMap<String,Object> attributes;
// per-request state
private transient ServletRequest request;
@@ -108,10 +107,8 @@ public class PageContextImpl extends PageContext {
}
@Override
- public void initialize(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL,
- boolean needsSession, int bufferSize, boolean autoFlush)
- throws IOException {
+ public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL,
+ boolean needsSession, int bufferSize, boolean autoFlush) throws IOException {
// initialize state
this.servlet = servlet;
@@ -180,7 +177,7 @@ public class PageContextImpl extends PageContext {
baseOut.recycle();
session = null;
attributes.clear();
- for (BodyContentImpl body: outs) {
+ for (BodyContentImpl body : outs) {
body.recycle();
}
}
@@ -199,23 +196,23 @@ public class PageContextImpl extends PageContext {
}
switch (scope) {
- case PAGE_SCOPE:
- return attributes.get(name);
+ case PAGE_SCOPE:
+ return attributes.get(name);
- case REQUEST_SCOPE:
- return request.getAttribute(name);
+ case REQUEST_SCOPE:
+ return request.getAttribute(name);
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
- }
- return session.getAttribute(name);
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ return session.getAttribute(name);
- case APPLICATION_SCOPE:
- return context.getAttribute(name);
+ case APPLICATION_SCOPE:
+ return context.getAttribute(name);
- default:
- throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
+ default:
+ throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
}
}
@@ -235,28 +232,27 @@ public class PageContextImpl extends PageContext {
removeAttribute(name, scope);
} else {
switch (scope) {
- case PAGE_SCOPE:
- attributes.put(name, o);
- break;
+ case PAGE_SCOPE:
+ attributes.put(name, o);
+ break;
- case REQUEST_SCOPE:
- request.setAttribute(name, o);
- break;
+ case REQUEST_SCOPE:
+ request.setAttribute(name, o);
+ break;
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(Localizer
- .getMessage("jsp.error.page.noSession"));
- }
- session.setAttribute(name, o);
- break;
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ session.setAttribute(name, o);
+ break;
- case APPLICATION_SCOPE:
- context.setAttribute(name, o);
- break;
+ case APPLICATION_SCOPE:
+ context.setAttribute(name, o);
+ break;
- default:
- throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
+ default:
+ throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
}
}
}
@@ -269,27 +265,27 @@ public class PageContextImpl extends PageContext {
}
switch (scope) {
- case PAGE_SCOPE:
- attributes.remove(name);
- break;
+ case PAGE_SCOPE:
+ attributes.remove(name);
+ break;
- case REQUEST_SCOPE:
- request.removeAttribute(name);
- break;
+ case REQUEST_SCOPE:
+ request.removeAttribute(name);
+ break;
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
- }
- session.removeAttribute(name);
- break;
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ session.removeAttribute(name);
+ break;
- case APPLICATION_SCOPE:
- context.removeAttribute(name);
- break;
+ case APPLICATION_SCOPE:
+ context.removeAttribute(name);
+ break;
- default:
- throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
+ default:
+ throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
}
}
@@ -313,7 +309,7 @@ public class PageContextImpl extends PageContext {
if (session.getAttribute(name) != null) {
return SESSION_SCOPE;
}
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall through to application scope.
}
@@ -345,7 +341,7 @@ public class PageContextImpl extends PageContext {
if (session != null) {
try {
o = session.getAttribute(name);
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall through to application scope.
}
@@ -360,23 +356,23 @@ public class PageContextImpl extends PageContext {
@Override
public Enumeration<String> getAttributeNamesInScope(final int scope) {
switch (scope) {
- case PAGE_SCOPE:
- return Collections.enumeration(attributes.keySet());
+ case PAGE_SCOPE:
+ return Collections.enumeration(attributes.keySet());
- case REQUEST_SCOPE:
- return request.getAttributeNames();
+ case REQUEST_SCOPE:
+ return request.getAttributeNames();
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
- }
- return session.getAttributeNames();
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ return session.getAttributeNames();
- case APPLICATION_SCOPE:
- return context.getAttributeNames();
+ case APPLICATION_SCOPE:
+ return context.getAttributeNames();
- default:
- throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
+ default:
+ throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope"));
}
}
@@ -389,10 +385,10 @@ public class PageContextImpl extends PageContext {
removeAttribute(name, PAGE_SCOPE);
removeAttribute(name, REQUEST_SCOPE);
- if( session != null ) {
+ if (session != null) {
try {
removeAttribute(name, SESSION_SCOPE);
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall throw to application scope.
}
@@ -433,8 +429,7 @@ public class PageContextImpl extends PageContext {
/**
* Returns the exception associated with this page context, if any.
* <p>
- * Added wrapping for Throwables to avoid ClassCastException: see Bugzilla
- * 31171 for details.
+ * Added wrapping for Throwables to avoid ClassCastException: see Bugzilla 31171 for details.
*
* @return The Exception associated with this page context, if any.
*/
@@ -459,8 +454,7 @@ public class PageContextImpl extends PageContext {
String path = relativeUrlPath;
if (!path.startsWith("/")) {
- String uri = (String) request.getAttribute(
- RequestDispatcher.INCLUDE_SERVLET_PATH);
+ String uri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
if (uri == null) {
uri = ((HttpServletRequest) request).getServletPath();
}
@@ -472,23 +466,19 @@ public class PageContextImpl extends PageContext {
}
@Override
- public void include(String relativeUrlPath) throws ServletException,
- IOException {
- JspRuntimeLibrary
- .include(request, response, relativeUrlPath, out, true);
+ public void include(String relativeUrlPath) throws ServletException, IOException {
+ JspRuntimeLibrary.include(request, response, relativeUrlPath, out, true);
}
@Override
- public void include(final String relativeUrlPath, final boolean flush)
- throws ServletException, IOException {
+ public void include(final String relativeUrlPath, final boolean flush) throws ServletException, IOException {
JspRuntimeLibrary.include(request, response, relativeUrlPath, out, flush);
}
@Override
@Deprecated
public javax.servlet.jsp.el.VariableResolver getVariableResolver() {
- return new org.apache.jasper.el.VariableResolverImpl(
- this.getELContext());
+ return new org.apache.jasper.el.VariableResolverImpl(this.getELContext());
}
@Override
@@ -498,8 +488,7 @@ public class PageContextImpl extends PageContext {
out.clear();
baseOut.clear();
} catch (IOException ex) {
- throw new IllegalStateException(Localizer.getMessage(
- "jsp.error.attempt_to_clear_flushed_buffer"), ex);
+ throw new IllegalStateException(Localizer.getMessage("jsp.error.attempt_to_clear_flushed_buffer"), ex);
}
// Make sure that the response object is not the wrapper for include
@@ -563,20 +552,17 @@ public class PageContextImpl extends PageContext {
}
/**
- * Provides programmatic access to the ExpressionEvaluator. The JSP
- * Container must return a valid instance of an ExpressionEvaluator that can
- * parse EL expressions.
+ * Provides programmatic access to the ExpressionEvaluator. The JSP Container must return a valid instance of an
+ * ExpressionEvaluator that can parse EL expressions.
*/
@Override
@Deprecated
public javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() {
- return new org.apache.jasper.el.ExpressionEvaluatorImpl(
- this.applicationContext.getExpressionFactory());
+ return new org.apache.jasper.el.ExpressionEvaluatorImpl(this.applicationContext.getExpressionFactory());
}
@Override
- public void handlePageException(Exception ex) throws IOException,
- ServletException {
+ public void handlePageException(Exception ex) throws IOException, ServletException {
// Should never be called since handleException() called with a
// Throwable in the generated servlet.
handlePageException((Throwable) ex);
@@ -592,13 +578,10 @@ public class PageContextImpl extends PageContext {
if (errorPageURL != null && !errorPageURL.equals("")) {
/*
- * Set request attributes. Do not set the
- * javax.servlet.error.exception attribute here (instead, set in the
- * generated servlet code for the error page) in order to prevent
- * the ErrorReportValve, which is invoked as part of forwarding the
- * request to the error page, from throwing it if the response has
- * not been committed (the response will have been committed if the
- * error page is a JSP page).
+ * Set request attributes. Do not set the javax.servlet.error.exception attribute here (instead, set in the
+ * generated servlet code for the error page) in order to prevent the ErrorReportValve, which is invoked as
+ * part of forwarding the request to the error page, from throwing it if the response has not been committed
+ * (the response will have been committed if the error page is a JSP page).
*/
request.setAttribute(EXCEPTION, t);
request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,
@@ -647,8 +630,7 @@ public class PageContextImpl extends PageContext {
}
if (rootCause != null) {
- throw new ServletException(
- t.getClass().getName() + ": " + t.getMessage(), rootCause);
+ throw new ServletException(t.getClass().getName() + ": " + t.getMessage(), rootCause);
}
throw new ServletException(t);
@@ -656,27 +638,22 @@ public class PageContextImpl extends PageContext {
}
/**
- * Proprietary method to evaluate EL expressions. XXX - This method should
- * go away once the EL interpreter moves out of JSTL and into its own
- * project. For now, this is necessary because the standard machinery is too
- * slow.
+ * Proprietary method to evaluate EL expressions. XXX - This method should go away once the EL interpreter moves out
+ * of JSTL and into its own project. For now, this is necessary because the standard machinery is too slow.
+ *
+ * @param expression The expression to be evaluated
+ * @param expectedType The expected resulting type
+ * @param pageContext The page context
+ * @param functionMap Maps prefix and name to Method
*
- * @param expression
- * The expression to be evaluated
- * @param expectedType
- * The expected resulting type
- * @param pageContext
- * The page context
- * @param functionMap
- * Maps prefix and name to Method
* @return The result of the evaluation
+ *
* @throws ELException If an error occurs during the evaluation
*/
- public static Object proprietaryEvaluate(final String expression,
- final Class<?> expectedType, final PageContext pageContext,
- final ProtectedFunctionMapper functionMap)
- throws ELException {
- final ExpressionFactory exprFactory = jspf.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
+ public static Object proprietaryEvaluate(final String expression, final Class<?> expectedType,
+ final PageContext pageContext, final ProtectedFunctionMapper functionMap) throws ELException {
+ final ExpressionFactory exprFactory =
+ jspf.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
ELContext ctx = pageContext.getELContext();
ELContextImpl ctxImpl;
if (ctx instanceof ELContextWrapper) {
diff --git a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
index 0882cb5339..f2a92d29b3 100644
--- a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
+++ b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
@@ -22,15 +22,14 @@ import java.util.HashMap;
import javax.servlet.jsp.el.FunctionMapper;
/**
- * Maps EL functions to their Java method counterparts. Keeps the actual Method
- * objects protected so that JSP pages can't indirectly do reflection.
+ * Maps EL functions to their Java method counterparts. Keeps the actual Method objects protected so that JSP pages
+ * can't indirectly do reflection.
*
* @author Mark Roth
* @author Kin-man Chung
*/
@SuppressWarnings("deprecation") // Have to support old JSP EL API
-public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
- implements FunctionMapper {
+public final class ProtectedFunctionMapper extends javax.el.FunctionMapper implements FunctionMapper {
/**
* Maps "prefix:name" to java.lang.Method objects.
@@ -49,8 +48,8 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
}
/**
- * Generated Servlet and Tag Handler implementations call this method to
- * retrieve an instance of the ProtectedFunctionMapper.
+ * Generated Servlet and Tag Handler implementations call this method to retrieve an instance of the
+ * ProtectedFunctionMapper.
*
* @return A new protected function mapper.
*/
@@ -61,22 +60,16 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
}
/**
- * Stores a mapping from the given EL function prefix and name to the given
- * Java method.
+ * Stores a mapping from the given EL function prefix and name to the given Java method.
*
- * @param fnQName
- * The EL function qualified name (including prefix)
- * @param c
- * The class containing the Java method
- * @param methodName
- * The name of the Java method
- * @param args
- * The arguments of the Java method
- * @throws RuntimeException
- * if no method with the given signature could be found.
+ * @param fnQName The EL function qualified name (including prefix)
+ * @param c The class containing the Java method
+ * @param methodName The name of the Java method
+ * @param args The arguments of the Java method
+ *
+ * @throws RuntimeException if no method with the given signature could be found.
*/
- public void mapFunction(String fnQName, final Class<?> c,
- final String methodName, final Class<?>[] args) {
+ public void mapFunction(String fnQName, final Class<?> c, final String methodName, final Class<?>[] args) {
// Skip if null values were passed in. They indicate a function
// added via a lambda or ImportHandler; nether of which need to be
// placed in the Map.
@@ -87,33 +80,27 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
try {
method = c.getMethod(methodName, args);
} catch (NoSuchMethodException e) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
+ throw new RuntimeException("Invalid function mapping - no such method: " + e.getMessage());
}
this.fnmap.put(fnQName, method);
}
/**
- * Creates an instance for this class, and stores the Method for the given
- * EL function prefix and name. This method is used for the case when there
- * is only one function in the EL expression.
+ * Creates an instance for this class, and stores the Method for the given EL function prefix and name. This method
+ * is used for the case when there is only one function in the EL expression.
+ *
+ * @param fnQName The EL function qualified name (including prefix)
+ * @param c The class containing the Java method
+ * @param methodName The name of the Java method
+ * @param args The arguments of the Java method
+ *
+ * @throws RuntimeException if no method with the given signature could be found.
*
- * @param fnQName
- * The EL function qualified name (including prefix)
- * @param c
- * The class containing the Java method
- * @param methodName
- * The name of the Java method
- * @param args
- * The arguments of the Java method
- * @throws RuntimeException
- * if no method with the given signature could be found.
* @return the mapped function
*/
- public static ProtectedFunctionMapper getMapForFunction(String fnQName,
- final Class<?> c, final String methodName, final Class<?>[] args) {
+ public static ProtectedFunctionMapper getMapForFunction(String fnQName, final Class<?> c, final String methodName,
+ final Class<?>[] args) {
Method method = null;
ProtectedFunctionMapper funcMapper = new ProtectedFunctionMapper();
// Skip if null values were passed in. They indicate a function
@@ -123,9 +110,7 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
try {
method = c.getMethod(methodName, args);
} catch (NoSuchMethodException e) {
- throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
+ throw new RuntimeException("Invalid function mapping - no such method: " + e.getMessage());
}
}
funcMapper.theMethod = method;
@@ -133,13 +118,12 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper
}
/**
- * Resolves the specified local name and prefix into a Java.lang.Method.
- * Returns null if the prefix and local name are not found.
+ * Resolves the specified local name and prefix into a Java.lang.Method. Returns null if the prefix and local name
+ * are not found.
+ *
+ * @param prefix the prefix of the function
+ * @param localName the short name of the function
*
- * @param prefix
- * the prefix of the function
- * @param localName
- * the short name of the function
* @return the result of the method mapping. Null means no entry found.
*/
@Override
diff --git a/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java b/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java
index 2806587aaf..4708127dcc 100644
--- a/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java
+++ b/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java
@@ -26,11 +26,8 @@ import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.jsp.JspWriter;
/**
- * ServletResponseWrapper used by the JSP 'include' action.
- *
- * This wrapper response object is passed to RequestDispatcher.include(), so
- * that the output of the included resource is appended to that of the
- * including page.
+ * ServletResponseWrapper used by the JSP 'include' action. This wrapper response object is passed to
+ * RequestDispatcher.include(), so that the output of the included resource is appended to that of the including page.
*
* @author Pierre Delisle
*/
@@ -44,9 +41,8 @@ public class ServletResponseWrapperInclude extends HttpServletResponseWrapper {
private final JspWriter jspWriter;
- public ServletResponseWrapperInclude(ServletResponse response,
- JspWriter jspWriter) {
- super((HttpServletResponse)response);
+ public ServletResponseWrapperInclude(ServletResponse response, JspWriter jspWriter) {
+ super((HttpServletResponse) response);
this.printWriter = new PrintWriter(jspWriter);
this.jspWriter = jspWriter;
}
@@ -65,8 +61,7 @@ public class ServletResponseWrapperInclude extends HttpServletResponseWrapper {
}
/**
- * Clears the output buffer of the JspWriter associated with the including
- * page.
+ * Clears the output buffer of the JspWriter associated with the including page.
*/
@Override
public void resetBuffer() {
diff --git a/java/org/apache/jasper/runtime/TagHandlerPool.java b/java/org/apache/jasper/runtime/TagHandlerPool.java
index 5f4e35cc70..f8a5e334ae 100644
--- a/java/org/apache/jasper/runtime/TagHandlerPool.java
+++ b/java/org/apache/jasper/runtime/TagHandlerPool.java
@@ -89,14 +89,14 @@ public class TagHandlerPool {
}
/**
- * Gets the next available tag handler from this tag handler pool,
- * instantiating one if this tag handler pool is empty.
+ * Gets the next available tag handler from this tag handler pool, instantiating one if this tag handler pool is
+ * empty.
+ *
+ * @param handlerClass Tag handler class
*
- * @param handlerClass
- * Tag handler class
* @return Reused or newly instantiated tag handler
- * @throws JspException
- * if a tag handler cannot be instantiated
+ *
+ * @throws JspException if a tag handler cannot be instantiated
*/
public Tag get(Class<? extends Tag> handlerClass) throws JspException {
Tag handler;
@@ -111,8 +111,7 @@ public class TagHandlerPool {
// wait for us to construct a tag for this thread.
try {
if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
- return (Tag) instanceManager.newInstance(
- handlerClass.getName(), handlerClass.getClassLoader());
+ return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader());
} else {
Tag instance = handlerClass.getConstructor().newInstance();
instanceManager.newInstance(instance);
@@ -126,12 +125,10 @@ public class TagHandlerPool {
}
/**
- * Adds the given tag handler to this tag handler pool, unless this tag
- * handler pool has already reached its capacity, in which case the tag
- * handler's release() method is called.
+ * Adds the given tag handler to this tag handler pool, unless this tag handler pool has already reached its
+ * capacity, in which case the tag handler's release() method is called.
*
- * @param handler
- * Tag handler to add to this tag handler pool
+ * @param handler Tag handler to add to this tag handler pool
*/
public void reuse(Tag handler) {
synchronized (this) {
@@ -145,8 +142,7 @@ public class TagHandlerPool {
}
/**
- * Calls the release() method of all available tag handlers in this tag
- * handler pool.
+ * Calls the release() method of all available tag handlers in this tag handler pool.
*/
public synchronized void release() {
for (int i = current; i >= 0; i--) {
@@ -155,8 +151,7 @@ public class TagHandlerPool {
}
- protected static String getOption(ServletConfig config, String name,
- String defaultV) {
+ protected static String getOption(ServletConfig config, String name, String defaultV) {
if (config == null) {
return defaultV;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org