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/20 15:17:49 UTC
(tomcat) branch 9.0.x updated (4b4022f5f9 -> 766777dae9)
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 4b4022f5f9 Fix IDE warnings
new 7e210947d2 Improve Javadoc formatting
new 555616e34a Don't reformat inserted code blocks.
new b7148ac33c Improve Javadoc formatting
new 766777dae9 Code clean-up - formatting. No functional change.
The 4 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:
java/org/apache/jasper/Constants.java | 74 ++--
java/org/apache/jasper/EmbeddedServletOptions.java | 89 ++---
java/org/apache/jasper/JasperException.java | 10 +-
java/org/apache/jasper/JspC.java | 443 +++++++++------------
java/org/apache/jasper/JspCompilationContext.java | 175 ++++----
java/org/apache/jasper/Options.java | 115 +++---
java/org/apache/jasper/tagplugins/jstl/Util.java | 123 +++---
.../apache/jasper/tagplugins/jstl/core/Catch.java | 30 +-
.../jasper/tagplugins/jstl/core/ForEach.java | 22 +-
.../jasper/tagplugins/jstl/core/ForTokens.java | 64 +--
.../apache/jasper/tagplugins/jstl/core/Import.java | 292 ++++++++------
.../apache/jasper/tagplugins/jstl/core/Out.java | 42 +-
.../apache/jasper/tagplugins/jstl/core/Param.java | 42 +-
.../jasper/tagplugins/jstl/core/Redirect.java | 41 +-
.../apache/jasper/tagplugins/jstl/core/Remove.java | 12 +-
.../apache/jasper/tagplugins/jstl/core/Set.java | 93 +++--
.../apache/jasper/tagplugins/jstl/core/Url.java | 50 ++-
.../apache/jasper/tagplugins/jstl/core/When.java | 2 +-
.../org/apache/jasper/util/FastRemovalDequeue.java | 99 ++---
.../apache/jasper/util/UniqueAttributesImpl.java | 13 +-
20 files changed, 869 insertions(+), 962 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 04/04: 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 766777dae93e4bd382e66e2acf7ab8a5ab3e3dac
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 20 15:17:44 2025 +0000
Code clean-up - formatting. No functional change.
---
java/org/apache/jasper/Constants.java | 74 ++--
java/org/apache/jasper/EmbeddedServletOptions.java | 89 ++---
java/org/apache/jasper/JasperException.java | 10 +-
java/org/apache/jasper/JspC.java | 443 +++++++++------------
java/org/apache/jasper/JspCompilationContext.java | 175 ++++----
java/org/apache/jasper/Options.java | 115 +++---
java/org/apache/jasper/tagplugins/jstl/Util.java | 119 +++---
.../apache/jasper/tagplugins/jstl/core/Catch.java | 30 +-
.../jasper/tagplugins/jstl/core/ForEach.java | 18 +-
.../jasper/tagplugins/jstl/core/ForTokens.java | 64 +--
.../apache/jasper/tagplugins/jstl/core/Import.java | 292 ++++++++------
.../apache/jasper/tagplugins/jstl/core/Out.java | 42 +-
.../apache/jasper/tagplugins/jstl/core/Param.java | 42 +-
.../jasper/tagplugins/jstl/core/Redirect.java | 41 +-
.../apache/jasper/tagplugins/jstl/core/Remove.java | 12 +-
.../apache/jasper/tagplugins/jstl/core/Set.java | 93 +++--
.../apache/jasper/tagplugins/jstl/core/Url.java | 50 ++-
.../apache/jasper/tagplugins/jstl/core/When.java | 2 +-
.../org/apache/jasper/util/FastRemovalDequeue.java | 87 ++--
.../apache/jasper/util/UniqueAttributesImpl.java | 13 +-
20 files changed, 859 insertions(+), 952 deletions(-)
diff --git a/java/org/apache/jasper/Constants.java b/java/org/apache/jasper/Constants.java
index 76be684d8f..bfbcbfa304 100644
--- a/java/org/apache/jasper/Constants.java
+++ b/java/org/apache/jasper/Constants.java
@@ -36,35 +36,29 @@ public class Constants {
* The base class of the generated servlets.
*/
public static final String JSP_SERVLET_BASE =
- System.getProperty("org.apache.jasper.Constants.JSP_SERVLET_BASE", "org.apache.jasper.runtime.HttpJspBase");
+ System.getProperty("org.apache.jasper.Constants.JSP_SERVLET_BASE", "org.apache.jasper.runtime.HttpJspBase");
/**
- * _jspService is the name of the method that is called by
- * HttpJspBase.service(). This is where most of the code generated
- * from JSPs go.
+ * _jspService is the name of the method that is called by HttpJspBase.service(). This is where most of the code
+ * generated from JSPs go.
*/
public static final String SERVICE_METHOD_NAME =
- System.getProperty("org.apache.jasper.Constants.SERVICE_METHOD_NAME", "_jspService");
+ System.getProperty("org.apache.jasper.Constants.SERVICE_METHOD_NAME", "_jspService");
/**
- * These classes/packages are automatically imported by the
- * generated code.
+ * These classes/packages are automatically imported by the generated code.
*/
- private static final String[] PRIVATE_STANDARD_IMPORTS = {
- "javax.servlet.*",
- "javax.servlet.http.*",
- "javax.servlet.jsp.*"
- };
+ private static final String[] PRIVATE_STANDARD_IMPORTS =
+ { "javax.servlet.*", "javax.servlet.http.*", "javax.servlet.jsp.*" };
public static final List<String> STANDARD_IMPORTS =
- Collections.unmodifiableList(Arrays.asList(PRIVATE_STANDARD_IMPORTS));
+ Collections.unmodifiableList(Arrays.asList(PRIVATE_STANDARD_IMPORTS));
/**
- * ServletContext attribute for classpath. This is tomcat specific.
- * Other servlet engines may choose to support this attribute if they
- * want to have this JSP engine running on them.
+ * ServletContext attribute for classpath. This is tomcat specific. Other servlet engines may choose to support this
+ * attribute if they want to have this JSP engine running on them.
*/
public static final String SERVLET_CLASSPATH =
- System.getProperty("org.apache.jasper.Constants.SERVLET_CLASSPATH", "org.apache.catalina.jsp_classpath");
+ System.getProperty("org.apache.jasper.Constants.SERVLET_CLASSPATH", "org.apache.catalina.jsp_classpath");
/**
* Default size of the JSP buffer.
@@ -82,23 +76,22 @@ public class Constants {
public static final int MAX_POOL_SIZE = 5;
/**
- * The query parameter that causes the JSP engine to just
- * pregenerated the servlet but not invoke it.
+ * The query parameter that causes the JSP engine to just pregenerated the servlet but not invoke it.
*/
public static final String PRECOMPILE =
- System.getProperty("org.apache.jasper.Constants.PRECOMPILE", "jsp_precompile");
+ System.getProperty("org.apache.jasper.Constants.PRECOMPILE", "jsp_precompile");
/**
* The default package name for compiled jsp pages.
*/
public static final String JSP_PACKAGE_NAME =
- System.getProperty("org.apache.jasper.Constants.JSP_PACKAGE_NAME", "org.apache.jsp");
+ System.getProperty("org.apache.jasper.Constants.JSP_PACKAGE_NAME", "org.apache.jsp");
/**
* The default package name for tag handlers generated from tag files
*/
public static final String TAG_FILE_PACKAGE_NAME =
- System.getProperty("org.apache.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
+ System.getProperty("org.apache.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
/**
* Default URLs to download the plugin for Netscape and IE.
@@ -106,58 +99,51 @@ public class Constants {
* @deprecated Will be removed in Tomcat 10.1 onwards
*/
@Deprecated
- public static final String NS_PLUGIN_URL =
- "http://java.sun.com/products/plugin/";
+ public static final String NS_PLUGIN_URL = "http://java.sun.com/products/plugin/";
@Deprecated
public static final String IE_PLUGIN_URL =
- "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
+ "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
/**
* Prefix to use for generated temporary variable names
*/
public static final String TEMP_VARIABLE_NAME_PREFIX =
- System.getProperty("org.apache.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX", "_jspx_temp");
+ System.getProperty("org.apache.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX", "_jspx_temp");
/**
* Has security been turned on?
*/
- public static final boolean IS_SECURITY_ENABLED =
- (System.getSecurityManager() != null);
+ public static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null);
- public static final boolean USE_INSTANCE_MANAGER_FOR_TAGS =
- Boolean.parseBoolean(System.getProperty("org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS", "false"));
+ public static final boolean USE_INSTANCE_MANAGER_FOR_TAGS = Boolean
+ .parseBoolean(System.getProperty("org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS", "false"));
/**
- * The name of the path parameter used to pass the session identifier
- * back and forth with the client.
+ * The name of the path parameter used to pass the session identifier back and forth with the client.
*/
public static final String SESSION_PARAMETER_NAME =
- System.getProperty("org.apache.catalina.SESSION_PARAMETER_NAME",
- "jsessionid");
+ System.getProperty("org.apache.catalina.SESSION_PARAMETER_NAME", "jsessionid");
/**
- * Name of the system property containing
- * the tomcat product installation path
+ * Name of the system property containing the tomcat product installation path
*/
public static final String CATALINA_HOME_PROP = "catalina.home";
/**
- * Name of the ServletContext init-param that determines if the XML parsers
- * used for *.tld files will be validating or not.
+ * Name of the ServletContext init-param that determines if the XML parsers used for *.tld files will be validating
+ * or not.
* <p>
* This must be kept in sync with org.apache.catalina.Globals
*/
- public static final String XML_VALIDATION_TLD_INIT_PARAM =
- "org.apache.jasper.XML_VALIDATE_TLD";
+ public static final String XML_VALIDATION_TLD_INIT_PARAM = "org.apache.jasper.XML_VALIDATE_TLD";
/**
- * Name of the ServletContext init-param that determines if the XML parsers
- * will block the resolution of external entities.
+ * Name of the ServletContext init-param that determines if the XML parsers will block the resolution of external
+ * entities.
* <p>
* This must be kept in sync with org.apache.catalina.Globals
*/
- public static final String XML_BLOCK_EXTERNAL_INIT_PARAM =
- "org.apache.jasper.XML_BLOCK_EXTERNAL";
+ public static final String XML_BLOCK_EXTERNAL_INIT_PARAM = "org.apache.jasper.XML_BLOCK_EXTERNAL";
}
diff --git a/java/org/apache/jasper/EmbeddedServletOptions.java b/java/org/apache/jasper/EmbeddedServletOptions.java
index fa00c6f3e9..e82732383d 100644
--- a/java/org/apache/jasper/EmbeddedServletOptions.java
+++ b/java/org/apache/jasper/EmbeddedServletOptions.java
@@ -73,9 +73,8 @@ public final class EmbeddedServletOptions implements Options {
private boolean isPoolingEnabled = true;
/**
- * Do you want support for "mapped" files? This will generate
- * servlet that has a print statement per line of the JSP file.
- * This seems like a really nice feature to have for debugging.
+ * Do you want support for "mapped" files? This will generate servlet that has a print statement per line of the JSP
+ * file. This seems like a really nice feature to have for debugging.
*/
private boolean mappedFile = true;
@@ -107,15 +106,13 @@ public final class EmbeddedServletOptions implements Options {
private boolean errorOnUseBeanInvalidClassAttribute = true;
/**
- * I want to see my generated servlets. Which directory are they
- * in?
+ * I want to see my generated servlets. Which directory are they in?
*/
private final File scratchDir;
/**
- * Need to have this as is for versions 4 and 5 of IE. Can be set from
- * the initParams so if it changes in the future all that is needed is
- * to have a jsp initParam of type ieClassId="<value>"
+ * Need to have this as is for versions 4 and 5 of IE. Can be set from the initParams so if it changes in the future
+ * all that is needed is to have a jsp initParam of type ieClassId="<value>"
*/
private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
@@ -160,8 +157,7 @@ public final class EmbeddedServletOptions implements Options {
private TagPluginManager tagPluginManager = null;
/**
- * Java platform encoding to generate the JSP
- * page servlet.
+ * Java platform encoding to generate the JSP page servlet.
*/
private String javaEncoding = "UTF-8";
@@ -181,43 +177,39 @@ public final class EmbeddedServletOptions implements Options {
private boolean xpoweredBy;
/**
- * Should we include a source fragment in exception messages, which could be displayed
- * to the developer ?
+ * Should we include a source fragment in exception messages, which could be displayed to the developer ?
*/
private boolean displaySourceFragment = true;
/**
- * The maximum number of loaded jsps per web-application. If there are more
- * jsps loaded, they will be unloaded.
+ * The maximum number of loaded jsps per web-application. If there are more jsps loaded, they will be unloaded.
*/
private int maxLoadedJsps = -1;
/**
- * The idle time in seconds after which a JSP is unloaded.
- * If unset or less or equal than 0, no jsps are unloaded.
+ * The idle time in seconds after which a JSP is unloaded. If unset or less or equal than 0, no jsps are unloaded.
*/
private int jspIdleTimeout = -1;
/**
- * Should JSP.1.6 be applied strictly to attributes defined using scriptlet
- * expressions?
+ * Should JSP.1.6 be applied strictly to attributes defined using scriptlet expressions?
*/
private boolean strictQuoteEscaping = true;
/**
- * When EL is used in JSP attribute values, should the rules for quoting of
- * attributes described in JSP.1.6 be applied to the expression?
+ * When EL is used in JSP attribute values, should the rules for quoting of attributes described in JSP.1.6 be
+ * applied to the expression?
*/
private boolean quoteAttributeEL = true;
- public String getProperty(String name ) {
- return settings.getProperty( name );
+ public String getProperty(String name) {
+ return settings.getProperty(name);
}
- public void setProperty(String name, String value ) {
- if (name != null && value != null){
- settings.setProperty( name, value );
+ public void setProperty(String name, String value) {
+ if (name != null && value != null) {
+ settings.setProperty(name, value);
}
}
@@ -375,7 +367,7 @@ public final class EmbeddedServletOptions implements Options {
}
@Override
- public Map<String, TagLibraryInfo> getCache() {
+ public Map<String,TagLibraryInfo> getCache() {
return null;
}
@@ -400,18 +392,18 @@ public final class EmbeddedServletOptions implements Options {
}
/**
- * Create an EmbeddedServletOptions object using data available from
- * ServletConfig and ServletContext.
- * @param config The Servlet config
+ * Create an EmbeddedServletOptions object using data available from ServletConfig and ServletContext.
+ *
+ * @param config The Servlet config
* @param context The Servlet context
*/
public EmbeddedServletOptions(ServletConfig config, ServletContext context) {
- Enumeration<String> enumeration=config.getInitParameterNames();
- while( enumeration.hasMoreElements() ) {
- String k=enumeration.nextElement();
- String v=config.getInitParameter( k );
- setProperty( k, v);
+ Enumeration<String> enumeration = config.getInitParameterNames();
+ while (enumeration.hasMoreElements()) {
+ String k = enumeration.nextElement();
+ String v = config.getInitParameter(k);
+ setProperty(k, v);
}
String keepgen = config.getInitParameter("keepgenerated");
@@ -441,8 +433,7 @@ public final class EmbeddedServletOptions implements Options {
this.isPoolingEnabled = true;
String poolingEnabledParam = config.getInitParameter("enablePooling");
- if (poolingEnabledParam != null
- && !poolingEnabledParam.equalsIgnoreCase("true")) {
+ if (poolingEnabledParam != null && !poolingEnabledParam.equalsIgnoreCase("true")) {
if (poolingEnabledParam.equalsIgnoreCase("false")) {
this.isPoolingEnabled = false;
} else {
@@ -468,9 +459,9 @@ public final class EmbeddedServletOptions implements Options {
String debugInfo = config.getInitParameter("classdebuginfo");
if (debugInfo != null) {
if (debugInfo.equalsIgnoreCase("true")) {
- this.classDebugInfo = true;
+ this.classDebugInfo = true;
} else if (debugInfo.equalsIgnoreCase("false")) {
- this.classDebugInfo = false;
+ this.classDebugInfo = false;
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.classDebugInfo"));
@@ -482,7 +473,7 @@ public final class EmbeddedServletOptions implements Options {
if (checkInterval != null) {
try {
this.checkInterval = Integer.parseInt(checkInterval);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
}
@@ -493,7 +484,7 @@ public final class EmbeddedServletOptions implements Options {
if (modificationTestInterval != null) {
try {
this.modificationTestInterval = Integer.parseInt(modificationTestInterval);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.modificationTestInterval"));
}
@@ -605,21 +596,19 @@ public final class EmbeddedServletOptions implements Options {
return;
}
- if (!(scratchDir.exists() && scratchDir.canRead() &&
- scratchDir.canWrite() && scratchDir.isDirectory())) {
- log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir",
- scratchDir.getAbsolutePath()));
+ if (!(scratchDir.exists() && scratchDir.canRead() && scratchDir.canWrite() && scratchDir.isDirectory())) {
+ log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir", scratchDir.getAbsolutePath()));
}
this.compiler = config.getInitParameter("compiler");
String compilerTargetVM = config.getInitParameter("compilerTargetVM");
- if(compilerTargetVM != null) {
+ if (compilerTargetVM != null) {
this.compilerTargetVM = compilerTargetVM;
}
String compilerSourceVM = config.getInitParameter("compilerSourceVM");
- if(compilerSourceVM != null) {
+ if (compilerSourceVM != null) {
this.compilerSourceVM = compilerSourceVM;
}
@@ -676,9 +665,9 @@ public final class EmbeddedServletOptions implements Options {
if (maxLoadedJsps != null) {
try {
this.maxLoadedJsps = Integer.parseInt(maxLoadedJsps);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
- log.warn(Localizer.getMessage("jsp.warning.maxLoadedJsps", ""+this.maxLoadedJsps));
+ log.warn(Localizer.getMessage("jsp.warning.maxLoadedJsps", "" + this.maxLoadedJsps));
}
}
}
@@ -687,9 +676,9 @@ public final class EmbeddedServletOptions implements Options {
if (jspIdleTimeout != null) {
try {
this.jspIdleTimeout = Integer.parseInt(jspIdleTimeout);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
- log.warn(Localizer.getMessage("jsp.warning.jspIdleTimeout", ""+this.jspIdleTimeout));
+ log.warn(Localizer.getMessage("jsp.warning.jspIdleTimeout", "" + this.jspIdleTimeout));
}
}
}
diff --git a/java/org/apache/jasper/JasperException.java b/java/org/apache/jasper/JasperException.java
index ddf226dd12..1aebceaf3d 100644
--- a/java/org/apache/jasper/JasperException.java
+++ b/java/org/apache/jasper/JasperException.java
@@ -17,8 +17,7 @@
package org.apache.jasper;
/**
- * Base class for all exceptions generated by the JSP engine. Makes it
- * convenient to catch just this at the top-level.
+ * Base class for all exceptions generated by the JSP engine. Makes it convenient to catch just this at the top-level.
*
* @author Anil K. Vijendran
*/
@@ -31,9 +30,9 @@ public class JasperException extends javax.servlet.ServletException {
}
/**
- * Creates a JasperException with the embedded exception and the reason for
- * throwing a JasperException.
- * @param reason The exception message
+ * Creates a JasperException with the embedded exception and the reason for throwing a JasperException.
+ *
+ * @param reason The exception message
* @param exception The root cause
*/
public JasperException(String reason, Throwable exception) {
@@ -42,6 +41,7 @@ public class JasperException extends javax.servlet.ServletException {
/**
* Creates a JasperException with the embedded exception.
+ *
* @param exception The root cause
*/
public JasperException(Throwable exception) {
diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java
index 166ba89399..877873b73a 100644
--- a/java/org/apache/jasper/JspC.java
+++ b/java/org/apache/jasper/JspC.java
@@ -65,14 +65,10 @@ import org.apache.tools.ant.util.FileUtils;
import org.xml.sax.SAXException;
/**
- * Shell for the jspc compiler. Handles all options associated with the
- * command line and creates compilation contexts which it then compiles
- * according to the specified options.
+ * Shell for the jspc compiler. Handles all options associated with the command line and creates compilation contexts
+ * which it then compiles according to the specified options. This version can process files from a _single_ webapp at
+ * once, i.e. a single docbase can be specified. It can be used as an Ant task using:
*
- * This version can process files from a _single_ webapp at once, i.e.
- * a single docbase can be specified.
- *
- * It can be used as an Ant task using:
* <pre>
* <taskdef classname="org.apache.jasper.JspC" name="jasper" >
* <classpath>
@@ -104,8 +100,7 @@ public class JspC extends Task implements Options {
}
@Deprecated
- public static final String DEFAULT_IE_CLASS_ID =
- "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
+ public static final String DEFAULT_IE_CLASS_ID = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
// Logger
private static final Log log = LogFactory.getLog(JspC.class);
@@ -145,7 +140,7 @@ public class JspC extends Task implements Options {
protected static final String SWITCH_QUOTE_ATTRIBUTE_EL = "-quoteAttributeEL";
protected static final String SWITCH_NO_QUOTE_ATTRIBUTE_EL = "-no-quoteAttributeEL";
protected static final String SWITCH_THREAD_COUNT = "-threadCount";
- protected static final String SHOW_SUCCESS ="-s";
+ protected static final String SHOW_SUCCESS = "-s";
protected static final String LIST_ERRORS = "-l";
protected static final int INC_WEBXML = 10;
protected static final int FRG_WEBXML = 15;
@@ -198,7 +193,7 @@ public class JspC extends Task implements Options {
protected boolean smapSuppressed = true;
protected boolean smapDumped = false;
protected boolean caching = true;
- protected final Map<String, TagLibraryInfo> cache = new HashMap<>();
+ protected final Map<String,TagLibraryInfo> cache = new HashMap<>();
protected String compiler = null;
@@ -208,8 +203,7 @@ public class JspC extends Task implements Options {
protected boolean classDebugInfo = true;
/**
- * Throw an exception if there's a compilation error, or swallow it.
- * Default is true to preserve old behavior.
+ * Throw an exception if there's a compilation error, or swallow it. Default is true to preserve old behavior.
*/
protected boolean failOnError = true;
@@ -219,8 +213,7 @@ public class JspC extends Task implements Options {
private boolean fork = false;
/**
- * The file extensions to be handled as JSP files.
- * Default list is .jsp and .jspx.
+ * The file extensions to be handled as JSP files. Default list is .jsp and .jspx.
*/
protected List<String> extensions;
@@ -230,14 +223,12 @@ public class JspC extends Task implements Options {
protected final List<String> pages = new ArrayList<>();
/**
- * Needs better documentation, this data member does.
- * True by default.
+ * Needs better documentation, this data member does. True by default.
*/
protected boolean errorOnUseBeanInvalidClassAttribute = true;
/**
- * The java file encoding. Default
- * is UTF-8. Added per bugzilla 19622.
+ * The java file encoding. Default is UTF-8. Added per bugzilla 19622.
*/
protected String javaEncoding = "UTF-8";
@@ -260,8 +251,7 @@ public class JspC extends Task implements Options {
protected JspCServletContext context;
/**
- * The runtime context.
- * Maintain a dummy JspRuntimeContext for compiling tag files.
+ * The runtime context. Maintain a dummy JspRuntimeContext for compiling tag files.
*/
protected JspRuntimeContext rctxt;
@@ -305,7 +295,9 @@ public class JspC extends Task implements Options {
/**
* Apply command-line arguments.
+ *
* @param arg The arguments
+ *
* @throws JasperException JSPC error
*/
public void setArgs(String[] arg) throws JasperException {
@@ -321,24 +313,24 @@ public class JspC extends Task implements Options {
listErrors = true;
} else if (tok.equals(SWITCH_OUTPUT_DIR)) {
tok = nextArg();
- setOutputDir( tok );
+ setOutputDir(tok);
} else if (tok.equals(SWITCH_PACKAGE_NAME)) {
targetPackage = nextArg();
} else if (tok.equals(SWITCH_COMPILE)) {
- compile=true;
+ compile = true;
} else if (tok.equals(SWITCH_FAIL_FAST)) {
failFast = true;
} else if (tok.equals(SWITCH_CLASS_NAME)) {
targetClassName = nextArg();
} else if (tok.equals(SWITCH_URI_BASE)) {
- uriBase=nextArg();
+ uriBase = nextArg();
} else if (tok.equals(SWITCH_URI_ROOT)) {
- setUriroot( nextArg());
+ setUriroot(nextArg());
} else if (tok.equals(SWITCH_FILE_WEBAPP)) {
- setUriroot( nextArg());
- } else if ( tok.equals( SHOW_SUCCESS ) ) {
+ setUriroot(nextArg());
+ } else if (tok.equals(SHOW_SUCCESS)) {
showSuccess = true;
- } else if ( tok.equals( LIST_ERRORS ) ) {
+ } else if (tok.equals(LIST_ERRORS)) {
listErrors = true;
} else if (tok.equals(SWITCH_WEBAPP_INC)) {
webxmlFile = nextArg();
@@ -378,8 +370,7 @@ public class JspC extends Task implements Options {
setClassPath(nextArg());
} else if (tok.startsWith(SWITCH_DIE)) {
try {
- dieLevel = Integer.parseInt(
- tok.substring(SWITCH_DIE.length()));
+ dieLevel = Integer.parseInt(tok.substring(SWITCH_DIE.length()));
} catch (NumberFormatException nfe) {
dieLevel = DEFAULT_DIE_LEVEL;
}
@@ -425,18 +416,17 @@ public class JspC extends Task implements Options {
}
// Add all extra arguments to the list of files
- while( true ) {
+ while (true) {
String file = nextFile();
- if( file==null ) {
+ if (file == null) {
break;
}
- pages.add( file );
+ pages.add(file);
}
}
/**
- * In JspC this always returns <code>true</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>true</code>. {@inheritDoc}
*/
@Override
public boolean getKeepGenerated() {
@@ -454,8 +444,7 @@ public class JspC extends Task implements Options {
}
/**
- * Sets the option to control handling of template text that consists
- * entirely of whitespace.
+ * Sets the option to control handling of template text that consists entirely of whitespace.
*
* @param ts New value
*/
@@ -481,6 +470,7 @@ public class JspC extends Task implements Options {
/**
* Sets the option to enable the tag handler pooling.
+ *
* @param poolingEnabled New value
*/
public void setPoolingEnabled(boolean poolingEnabled) {
@@ -494,6 +484,7 @@ public class JspC extends Task implements Options {
/**
* Sets the option to enable generation of X-Powered-By response header.
+ *
* @param xpoweredBy New value
*/
public void setXpoweredBy(boolean xpoweredBy) {
@@ -501,8 +492,7 @@ public class JspC extends Task implements Options {
}
/**
- * In JspC this always returns <code>true</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>true</code>. {@inheritDoc}
*/
@Override
public boolean getDisplaySourceFragment() {
@@ -525,8 +515,8 @@ public class JspC extends Task implements Options {
}
/**
- * Sets the option to issue a compilation error if the class attribute
- * specified in useBean action is invalid.
+ * Sets the option to issue a compilation error if the class attribute specified in useBean action is invalid.
+ *
* @param b New value
*/
public void setErrorOnUseBeanInvalidClassAttribute(boolean b) {
@@ -544,10 +534,11 @@ public class JspC extends Task implements Options {
/**
* Sets the option to include debug information in compiled class.
+ *
* @param b New value
*/
- public void setClassDebugInfo( boolean b ) {
- classDebugInfo=b;
+ public void setClassDebugInfo(boolean b) {
+ classDebugInfo = b;
}
@Override
@@ -563,6 +554,7 @@ public class JspC extends Task implements Options {
/**
* Sets the option to enable caching.
+ *
* @param caching New value
*
* @see Options#isCaching()
@@ -572,13 +564,12 @@ public class JspC extends Task implements Options {
}
@Override
- public Map<String, TagLibraryInfo> getCache() {
+ public Map<String,TagLibraryInfo> getCache() {
return cache;
}
/**
- * In JspC this always returns <code>0</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>0</code>. {@inheritDoc}
*/
@Override
public int getCheckInterval() {
@@ -586,8 +577,7 @@ public class JspC extends Task implements Options {
}
/**
- * In JspC this always returns <code>0</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>0</code>. {@inheritDoc}
*/
@Override
public int getModificationTestInterval() {
@@ -596,8 +586,7 @@ public class JspC extends Task implements Options {
/**
- * In JspC this always returns <code>false</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>false</code>. {@inheritDoc}
*/
@Override
public boolean getRecompileOnFail() {
@@ -606,8 +595,7 @@ public class JspC extends Task implements Options {
/**
- * In JspC this always returns <code>false</code>.
- * {@inheritDoc}
+ * In JspC this always returns <code>false</code>. {@inheritDoc}
*/
@Override
public boolean getDevelopment() {
@@ -621,6 +609,7 @@ public class JspC extends Task implements Options {
/**
* Sets smapSuppressed flag.
+ *
* @param smapSuppressed New value
*/
public void setSmapSuppressed(boolean smapSuppressed) {
@@ -634,6 +623,7 @@ public class JspC extends Task implements Options {
/**
* Sets smapDumped flag.
+ *
* @param smapDumped New value
*
* @see Options#isSmapDumped()
@@ -644,11 +634,9 @@ public class JspC extends Task implements Options {
/**
- * Determines whether text strings are to be generated as char arrays,
- * which improves performance in some cases.
+ * Determines whether text strings are to be generated as char arrays, which improves performance in some cases.
*
- * @param genStringAsCharArray true if text strings are to be generated as
- * char arrays, false otherwise
+ * @param genStringAsCharArray true if text strings are to be generated as char arrays, false otherwise
*/
public void setGenStringAsCharArray(boolean genStringAsCharArray) {
this.genStringAsCharArray = genStringAsCharArray;
@@ -660,11 +648,9 @@ public class JspC extends Task implements Options {
}
/**
- * Sets the class-id value to be sent to Internet Explorer when using
- * <jsp:plugin> tags.
+ * Sets the class-id value to be sent to Internet Explorer when using <jsp:plugin> tags.
*
- * @param ieClassId
- * Class-id value
+ * @param ieClassId Class-id value
*
* @deprecated Will be removed in Tomcat 10.1
*/
@@ -691,12 +677,13 @@ public class JspC extends Task implements Options {
/**
* Sets the option to determine what compiler to use.
+ *
* @param c New value
*
* @see Options#getCompiler()
*/
public void setCompiler(String c) {
- compiler=c;
+ compiler = c;
}
@Override
@@ -711,6 +698,7 @@ public class JspC extends Task implements Options {
/**
* Sets the compiler target VM.
+ *
* @param vm New value
*
* @see Options#getCompilerTargetVM()
@@ -719,17 +707,18 @@ public class JspC extends Task implements Options {
compilerTargetVM = vm;
}
- @Override
+ @Override
public String getCompilerSourceVM() {
- return compilerSourceVM;
- }
-
- /**
- * Sets the compiler source VM.
- * @param vm New value
- *
- * @see Options#getCompilerSourceVM()
- */
+ return compilerSourceVM;
+ }
+
+ /**
+ * Sets the compiler source VM.
+ *
+ * @param vm New value
+ *
+ * @see Options#getCompilerSourceVM()
+ */
public void setCompilerSourceVM(String vm) {
compilerSourceVM = vm;
}
@@ -740,8 +729,7 @@ public class JspC extends Task implements Options {
}
/**
- * Returns the encoding to use for
- * java files. The default is UTF-8.
+ * Returns the encoding to use for java files. The default is UTF-8.
*
* @return String The encoding
*/
@@ -751,8 +739,7 @@ public class JspC extends Task implements Options {
}
/**
- * Sets the encoding to use for
- * java files.
+ * Sets the encoding to use for java files.
*
* @param encodingName The name, e.g. "UTF-8"
*/
@@ -771,24 +758,23 @@ public class JspC extends Task implements Options {
@Override
public String getClassPath() {
- if( classPath != null ) {
+ if (classPath != null) {
return classPath;
}
return System.getProperty("java.class.path");
}
/**
- * Sets the classpath used while compiling the servlets generated from JSP
- * files
- * @param s New value
+ * Sets the classpath used while compiling the servlets generated from JSP files
+ *
+ * @param s New value
*/
public void setClassPath(String s) {
- classPath=s;
+ classPath = s;
}
/**
- * Returns the list of file extensions
- * that are treated as JSP files.
+ * Returns the list of file extensions that are treated as JSP files.
*
* @return The list of extensions
*/
@@ -797,14 +783,13 @@ public class JspC extends Task implements Options {
}
/**
- * Adds the given file extension to the
- * list of extensions handled as JSP files.
+ * Adds the given file extension to the list of extensions handled as JSP files.
*
* @param extension The extension to add, e.g. "myjsp"
*/
protected void addExtension(final String extension) {
- if(extension != null) {
- if(extensions == null) {
+ if (extension != null) {
+ if (extensions == null) {
extensions = new ArrayList<>();
}
@@ -813,33 +798,32 @@ public class JspC extends Task implements Options {
}
/**
- * Base dir for the webapp. Used to generate class names and resolve
- * includes.
+ * Base dir for the webapp. Used to generate class names and resolve includes.
+ *
* @param s New value
*/
- public void setUriroot( String s ) {
+ public void setUriroot(String s) {
if (s == null) {
uriRoot = null;
return;
}
try {
uriRoot = resolveFile(s).getCanonicalPath();
- } catch( Exception ex ) {
+ } catch (Exception ex) {
uriRoot = s;
}
}
/**
- * Parses comma-separated list of JSP files to be processed. If the argument
- * is null, nothing is done.
- *
- * <p>Each file is interpreted relative to uriroot, unless it is absolute,
- * in which case it must start with uriroot.</p>
+ * Parses comma-separated list of JSP files to be processed. If the argument is null, nothing is done.
+ * <p>
+ * Each file is interpreted relative to uriroot, unless it is absolute, in which case it must start with uriroot.
+ * </p>
*
* @param jspFiles Comma-separated list of JSP files to be processed
*/
public void setJspFiles(final String jspFiles) {
- if(jspFiles == null) {
+ if (jspFiles == null) {
return;
}
@@ -854,18 +838,17 @@ public class JspC extends Task implements Options {
*
* @param b Flag value
*/
- public void setCompile( final boolean b ) {
+ public void setCompile(final boolean b) {
compile = b;
}
/**
- * Sets the verbosity level. The actual number doesn't
- * matter: if it's greater than zero, the verbose flag will
- * be true.
+ * Sets the verbosity level. The actual number doesn't matter: if it's greater than zero, the verbose flag will be
+ * true.
*
* @param level Positive means verbose
*/
- public void setVerbose( final int level ) {
+ public void setVerbose(final int level) {
if (level > 0) {
verbose = true;
showSuccess = true;
@@ -873,7 +856,7 @@ public class JspC extends Task implements Options {
}
}
- public void setValidateTld( boolean b ) {
+ public void setValidateTld(boolean b) {
this.validateTld = b;
}
@@ -881,7 +864,7 @@ public class JspC extends Task implements Options {
return validateTld;
}
- public void setValidateXml( boolean b ) {
+ public void setValidateXml(boolean b) {
this.validateXml = b;
}
@@ -889,7 +872,7 @@ public class JspC extends Task implements Options {
return validateXml;
}
- public void setBlockExternal( boolean b ) {
+ public void setBlockExternal(boolean b) {
this.blockExternal = b;
}
@@ -897,7 +880,7 @@ public class JspC extends Task implements Options {
return blockExternal;
}
- public void setStrictQuoteEscaping( boolean b ) {
+ public void setStrictQuoteEscaping(boolean b) {
this.strictQuoteEscaping = b;
}
@@ -935,106 +918,104 @@ public class JspC extends Task implements Options {
throw new BuildException(Localizer.getMessage("jspc.error.parseThreadCount", threadCount));
}
if (newThreadCount < 1) {
- throw new BuildException(Localizer.getMessage(
- "jspc.error.minThreadCount", Integer.valueOf(newThreadCount)));
+ throw new BuildException(
+ Localizer.getMessage("jspc.error.minThreadCount", Integer.valueOf(newThreadCount)));
}
this.threadCount = newThreadCount;
}
- public void setListErrors( boolean b ) {
+ public void setListErrors(boolean b) {
listErrors = b;
}
- public void setOutputDir( String s ) {
- if( s!= null ) {
+ public void setOutputDir(String s) {
+ if (s != null) {
scratchDir = resolveFile(s).getAbsoluteFile();
} else {
- scratchDir=null;
+ scratchDir = null;
}
}
/**
* Sets the package name to be used for the generated servlet classes.
+ *
* @param p New value
*/
- public void setPackage( String p ) {
- targetPackage=p;
+ public void setPackage(String p) {
+ targetPackage = p;
}
/**
- * Class name of the generated file ( without package ).
- * Can only be used if a single file is converted.
- * XXX Do we need this feature ?
+ * Class name of the generated file ( without package ). Can only be used if a single file is converted. XXX Do we
+ * need this feature ?
+ *
* @param p New value
*/
- public void setClassName( String p ) {
- targetClassName=p;
+ public void setClassName(String p) {
+ targetClassName = p;
}
/**
* File where we generate a web.xml fragment with the class definitions.
+ *
* @param s New value
- * @deprecated Will be removed in Tomcat 10.
- * Use {@link #setWebXmlInclude(String)}
+ *
+ * @deprecated Will be removed in Tomcat 10. Use {@link #setWebXmlInclude(String)}
*/
@Deprecated
- public void setWebXmlFragment( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=INC_WEBXML;
+ public void setWebXmlFragment(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = INC_WEBXML;
}
/**
- * File where we generate configuration with the class definitions to be
- * included in a web.xml file.
+ * File where we generate configuration with the class definitions to be included in a web.xml file.
+ *
* @param s New value
*/
- public void setWebXmlInclude( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=INC_WEBXML;
+ public void setWebXmlInclude(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = INC_WEBXML;
}
/**
- * File where we generate a complete web-fragment.xml with the class
- * definitions.
+ * File where we generate a complete web-fragment.xml with the class definitions.
+ *
* @param s New value
*/
- public void setWebFragmentXml( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=FRG_WEBXML;
+ public void setWebFragmentXml(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = FRG_WEBXML;
}
/**
* File where we generate a complete web.xml with the class definitions.
+ *
* @param s New value
*/
- public void setWebXml( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=ALL_WEBXML;
+ public void setWebXml(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = ALL_WEBXML;
}
/**
* Sets the encoding to be used to read and write web.xml files.
- *
* <p>
* If not specified, defaults to UTF-8.
* </p>
*
- * @param encoding
- * Encoding, e.g. "UTF-8".
+ * @param encoding Encoding, e.g. "UTF-8".
*/
public void setWebXmlEncoding(String encoding) {
webxmlEncoding = encoding;
}
/**
- * Sets the option to merge generated web.xml fragment into the
- * WEB-INF/web.xml file of the web application that we were processing.
+ * Sets the option to merge generated web.xml fragment into the WEB-INF/web.xml file of the web application that we
+ * were processing.
*
- * @param b
- * <code>true</code> to merge the fragment into the existing
- * web.xml file of the processed web application
- * ({uriroot}/WEB-INF/web.xml), <code>false</code> to keep the
- * generated web.xml fragment
+ * @param b <code>true</code> to merge the fragment into the existing web.xml file of the processed web application
+ * ({uriroot}/WEB-INF/web.xml), <code>false</code> to keep the generated web.xml fragment
*/
public void setAddWebXmlMappings(boolean b) {
addWebXmlMappings = b;
@@ -1042,6 +1023,7 @@ public class JspC extends Task implements Options {
/**
* Sets the option that throws an exception in case of a compilation error.
+ *
* @param b New value
*/
public void setFailOnError(final boolean b) {
@@ -1049,8 +1031,7 @@ public class JspC extends Task implements Options {
}
/**
- * @return <code>true</code> if an exception will be thrown
- * in case of a compilation error.
+ * @return <code>true</code> if an exception will be thrown in case of a compilation error.
*/
public boolean getFailOnError() {
return failOnError;
@@ -1070,8 +1051,7 @@ public class JspC extends Task implements Options {
/**
* {@inheritDoc}
* <p>
- * Hard-coded to {@code false} for pre-compiled code to enable repeatable
- * builds.
+ * Hard-coded to {@code false} for pre-compiled code to enable repeatable builds.
*/
@Override
public boolean getGeneratedJavaAddTimestamp() {
@@ -1080,19 +1060,14 @@ public class JspC extends Task implements Options {
/**
- * Adds servlet declaration and mapping for the JSP page servlet to the
- * generated web.xml fragment.
+ * Adds servlet declaration and mapping for the JSP page servlet to the generated web.xml fragment.
+ *
+ * @param file Context-relative path to the JSP file, e.g. <code>/index.jsp</code>
+ * @param clctxt Compilation context of the servlet
*
- * @param file
- * Context-relative path to the JSP file, e.g.
- * <code>/index.jsp</code>
- * @param clctxt
- * Compilation context of the servlet
* @throws IOException An IO error occurred
*/
- public void generateWebMapping( String file, JspCompilationContext clctxt )
- throws IOException
- {
+ public void generateWebMapping(String file, JspCompilationContext clctxt) throws IOException {
if (log.isDebugEnabled()) {
log.debug(Localizer.getMessage("jspc.generatingMapping", file, clctxt));
}
@@ -1101,14 +1076,14 @@ public class JspC extends Task implements Options {
String packageName = clctxt.getServletPackageName();
String thisServletName;
- if (packageName.isEmpty()) {
+ if (packageName.isEmpty()) {
thisServletName = className;
} else {
thisServletName = packageName + '.' + className;
}
if (servletout != null) {
- synchronized(servletout) {
+ synchronized (servletout) {
servletout.write("\n <servlet>\n <servlet-name>");
servletout.write(thisServletName);
servletout.write("</servlet-name>\n <servlet-class>");
@@ -1117,7 +1092,7 @@ public class JspC extends Task implements Options {
}
}
if (mappingout != null) {
- synchronized(mappingout) {
+ synchronized (mappingout) {
mappingout.write("\n <servlet-mapping>\n <servlet-name>");
mappingout.write(thisServletName);
mappingout.write("</servlet-name>\n <url-pattern>");
@@ -1129,6 +1104,7 @@ public class JspC extends Task implements Options {
/**
* Include the generated web.xml inside the webapp's web.xml.
+ *
* @throws IOException An IO error occurred
*/
protected void mergeIntoWebXml() throws IOException {
@@ -1136,14 +1112,11 @@ public class JspC extends Task implements Options {
File webappBase = new File(uriRoot);
File webXml = new File(webappBase, "WEB-INF/web.xml");
File webXml2 = new File(webappBase, "WEB-INF/web2.xml");
- String insertStartMarker =
- Localizer.getMessage("jspc.webinc.insertStart");
- String insertEndMarker =
- Localizer.getMessage("jspc.webinc.insertEnd");
+ String insertStartMarker = Localizer.getMessage("jspc.webinc.insertStart");
+ String insertEndMarker = Localizer.getMessage("jspc.webinc.insertEnd");
try (BufferedReader reader = new BufferedReader(openWebxmlReader(webXml));
- BufferedReader fragmentReader =
- new BufferedReader(openWebxmlReader(new File(webxmlFile)));
+ BufferedReader fragmentReader = new BufferedReader(openWebxmlReader(new File(webxmlFile)));
PrintWriter writer = new PrintWriter(openWebxmlWriter(webXml2))) {
// Insert the <servlet> and <servlet-mapping> declarations
@@ -1195,8 +1168,7 @@ public class JspC extends Task implements Options {
}
}
- try (FileInputStream fis = new FileInputStream(webXml2);
- FileOutputStream fos = new FileOutputStream(webXml)) {
+ try (FileInputStream fis = new FileInputStream(webXml2); FileOutputStream fos = new FileOutputStream(webXml)) {
byte[] buf = new byte[512];
while (true) {
@@ -1208,9 +1180,8 @@ public class JspC extends Task implements Options {
}
}
- if(!webXml2.delete() && log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jspc.delete.fail",
- webXml2.toString()));
+ if (!webXml2.delete() && log.isDebugEnabled()) {
+ log.debug(Localizer.getMessage("jspc.delete.fail", webXml2.toString()));
}
if (!(new File(webxmlFile)).delete() && log.isDebugEnabled()) {
@@ -1273,9 +1244,8 @@ public class JspC extends Task implements Options {
scratchDir = new File(temp).getAbsoluteFile();
}
- String jspUri=file.replace('\\','/');
- JspCompilationContext clctxt = new JspCompilationContext
- ( jspUri, this, context, null, rctxt );
+ String jspUri = file.replace('\\', '/');
+ JspCompilationContext clctxt = new JspCompilationContext(jspUri, this, context, null, rctxt);
/* Override the defaults */
if ((targetClassName != null) && (!targetClassName.isEmpty())) {
@@ -1298,7 +1268,7 @@ public class JspC extends Task implements Options {
// .jsp file is newer than .class file;
// Otherwise only generate .java, if .jsp file is newer than
// the .java file
- if( clc.isOutDated(compile) ) {
+ if (clc.isOutDated(compile)) {
if (log.isDebugEnabled()) {
log.debug(Localizer.getMessage("jspc.outdated", jspUri));
}
@@ -1307,27 +1277,23 @@ public class JspC extends Task implements Options {
}
// Generate mapping
- generateWebMapping( file, clctxt );
- if ( showSuccess ) {
+ generateWebMapping(file, clctxt);
+ if (showSuccess) {
log.info(Localizer.getMessage("jspc.built", file));
}
} catch (JasperException je) {
Throwable rootCause = je;
- while (rootCause instanceof JasperException
- && ((JasperException) rootCause).getRootCause() != null) {
+ while (rootCause instanceof JasperException && ((JasperException) rootCause).getRootCause() != null) {
rootCause = ((JasperException) rootCause).getRootCause();
}
if (rootCause != je) {
- log.error(Localizer.getMessage("jspc.error.generalException",
- file),
- rootCause);
+ log.error(Localizer.getMessage("jspc.error.generalException", file), rootCause);
}
throw je;
} catch (Exception e) {
if ((e instanceof FileNotFoundException) && log.isWarnEnabled()) {
- log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist",
- e.getMessage()));
+ log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist", e.getMessage()));
}
throw new JasperException(e);
} finally {
@@ -1338,8 +1304,8 @@ public class JspC extends Task implements Options {
}
/**
- * Locate all jsp files in the webapp. Used if no explicit
- * jsps are specified.
+ * Locate all jsp files in the webapp. Used if no explicit jsps are specified.
+ *
* @param base Base path
*
* @deprecated This will be removed in Tomcat 10. Use {@link #scanFiles()}
@@ -1351,9 +1317,8 @@ public class JspC extends Task implements Options {
/**
- * Locate all jsp files in the webapp. Used if no explicit jsps are
- * specified. Scan is performed via the ServletContext and will include any
- * JSPs located in resource JARs.
+ * Locate all jsp files in the webapp. Used if no explicit jsps are specified. Scan is performed via the
+ * ServletContext and will include any JSPs located in resource JARs.
*/
public void scanFiles() {
// Make sure default extensions are always included
@@ -1388,7 +1353,7 @@ public class JspC extends Task implements Options {
*/
@Override
public void execute() {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug(Localizer.getMessage("jspc.start", Integer.toString(pages.size())));
}
@@ -1400,8 +1365,7 @@ public class JspC extends Task implements Options {
String firstJsp = pages.get(0);
File firstJspF = new File(firstJsp);
if (!firstJspF.exists()) {
- throw new JasperException(Localizer.getMessage(
- "jspc.error.fileDoesNotExist", firstJsp));
+ throw new JasperException(Localizer.getMessage("jspc.error.fileDoesNotExist", firstJsp));
}
locateUriRoot(firstJspF);
}
@@ -1439,8 +1403,7 @@ public class JspC extends Task implements Options {
}
if (!fjsp.exists()) {
if (log.isWarnEnabled()) {
- log.warn(Localizer.getMessage(
- "jspc.error.fileDoesNotExist", fjsp.toString()));
+ log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist", fjsp.toString()));
}
continue;
}
@@ -1499,11 +1462,10 @@ public class JspC extends Task implements Options {
}
long time = System.currentTimeMillis() - start;
- String msg = Localizer.getMessage("jspc.generation.result",
- Integer.toString(errorCount), Long.toString(time));
+ String msg =
+ Localizer.getMessage("jspc.generation.result", Integer.toString(errorCount), Long.toString(time));
if (failOnError && errorCount > 0) {
- System.out.println(Localizer.getMessage(
- "jspc.errorCount", Integer.valueOf(errorCount)));
+ System.out.println(Localizer.getMessage("jspc.errorCount", Integer.valueOf(errorCount)));
throw new BuildException(msg);
} else {
log.info(msg);
@@ -1532,8 +1494,7 @@ public class JspC extends Task implements Options {
// ==================== protected utility methods ====================
protected String nextArg() {
- if ((argPos >= args.length)
- || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
+ if ((argPos >= args.length) || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
return null;
} else {
return args[argPos++];
@@ -1566,9 +1527,9 @@ public class JspC extends Task implements Options {
mapout.write(Localizer.getMessage("jspc.webxml.header", webxmlEncoding));
mapout.flush();
} else if (webxmlLevel >= FRG_WEBXML) {
- mapout.write(Localizer.getMessage("jspc.webfrg.header", webxmlEncoding));
- mapout.flush();
- } else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
+ mapout.write(Localizer.getMessage("jspc.webfrg.header", webxmlEncoding));
+ mapout.flush();
+ } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
mapout.write(Localizer.getMessage("jspc.webinc.header"));
mapout.flush();
}
@@ -1588,7 +1549,7 @@ public class JspC extends Task implements Options {
if (webxmlLevel >= ALL_WEBXML) {
mapout.write(Localizer.getMessage("jspc.webxml.footer"));
} else if (webxmlLevel >= FRG_WEBXML) {
- mapout.write(Localizer.getMessage("jspc.webfrg.footer"));
+ mapout.write(Localizer.getMessage("jspc.webfrg.footer"));
} else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
mapout.write(Localizer.getMessage("jspc.webinc.footer"));
}
@@ -1610,20 +1571,18 @@ public class JspC extends Task implements Options {
}
- protected TldScanner newTldScanner(JspCServletContext context, boolean namespaceAware,
- boolean validate, boolean blockExternal) {
+ protected TldScanner newTldScanner(JspCServletContext context, boolean namespaceAware, boolean validate,
+ boolean blockExternal) {
return new TldScanner(context, namespaceAware, validate, blockExternal);
}
- protected void initServletContext(ClassLoader classLoader)
- throws IOException, JasperException {
+ protected void initServletContext(ClassLoader classLoader) throws IOException, JasperException {
// TODO: should we use the Ant Project's log?
PrintWriter log = new PrintWriter(System.out);
URL resourceBase = new File(uriRoot).getCanonicalFile().toURI().toURL();
- context = new JspCServletContext(log, resourceBase, classLoader,
- isValidateXml(), isBlockExternal());
+ context = new JspCServletContext(log, resourceBase, classLoader, isValidateXml(), isBlockExternal());
if (isValidateTld()) {
context.setInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM, "true");
}
@@ -1636,8 +1595,7 @@ public class JspC extends Task implements Options {
} catch (SAXException e) {
throw new JasperException(e);
}
- tldCache = new TldCache(context, scanner.getUriTldResourcePathMap(),
- scanner.getTldResourcePathTaglibXmlMap());
+ tldCache = new TldCache(context, scanner.getUriTldResourcePathMap(), scanner.getTldResourcePathTaglibXmlMap());
context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME, tldCache);
rctxt = new JspRuntimeContext(context, this);
jspConfig = new JspConfig(context);
@@ -1645,9 +1603,10 @@ public class JspC extends Task implements Options {
}
/**
- * Initializes the classloader as/if needed for the given
- * compilation context.
+ * Initializes the classloader as/if needed for the given compilation context.
+ *
* @return the classloader that will be used
+ *
* @throws IOException If an error occurs
*/
protected ClassLoader initClassLoader() throws IOException {
@@ -1656,14 +1615,12 @@ public class JspC extends Task implements Options {
ClassLoader jspcLoader = getClass().getClassLoader();
if (jspcLoader instanceof AntClassLoader) {
- classPath += File.pathSeparator
- + ((AntClassLoader) jspcLoader).getClasspath();
+ classPath += File.pathSeparator + ((AntClassLoader) jspcLoader).getClasspath();
}
// Turn the classPath into URLs
List<URL> urls = new ArrayList<>();
- StringTokenizer tokenizer = new StringTokenizer(classPath,
- File.pathSeparator);
+ StringTokenizer tokenizer = new StringTokenizer(classPath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken();
try {
@@ -1682,8 +1639,7 @@ public class JspC extends Task implements Options {
File classes = new File(webappBase, "/WEB-INF/classes");
try {
if (classes.exists()) {
- classPath = classPath + File.pathSeparator
- + classes.getCanonicalPath();
+ classPath = classPath + File.pathSeparator + classes.getCanonicalPath();
urls.add(classes.getCanonicalFile().toURI().toURL());
}
} catch (IOException ioe) {
@@ -1728,12 +1684,12 @@ public class JspC extends Task implements Options {
}
/**
- * Find the WEB-INF dir by looking up in the directory tree.
- * This is used if no explicit docbase is set, but only files.
+ * Find the WEB-INF dir by looking up in the directory tree. This is used if no explicit docbase is set, but only
+ * files.
*
* @param f The path from which it will start looking
*/
- protected void locateUriRoot( File f ) {
+ protected void locateUriRoot(File f) {
String tUriBase = uriBase;
if (tUriBase == null) {
tUriBase = "/";
@@ -1747,9 +1703,7 @@ public class JspC extends Task implements Options {
uriRoot = f.getCanonicalPath();
uriBase = tUriBase;
if (log.isInfoEnabled()) {
- log.info(Localizer.getMessage(
- "jspc.implicit.uriRoot",
- uriRoot));
+ log.info(Localizer.getMessage("jspc.implicit.uriRoot", uriRoot));
}
break;
}
@@ -1779,30 +1733,26 @@ public class JspC extends Task implements Options {
}
/**
- * Resolves the relative or absolute pathname correctly
- * in both Ant and command-line situations. If Ant launched
- * us, we should use the basedir of the current project
- * to resolve relative paths.
- *
- * See Bugzilla 35571.
+ * Resolves the relative or absolute pathname correctly in both Ant and command-line situations. If Ant launched us,
+ * we should use the basedir of the current project to resolve relative paths. See Bugzilla 35571.
*
* @param s The file
+ *
* @return The file resolved
*/
- protected File resolveFile(final String s) {
- if(getProject() == null) {
- // Note FileUtils.getFileUtils replaces FileUtils.newFileUtils in Ant 1.6.3
- return FileUtils.getFileUtils().resolveFile(null, s);
- } else {
- return FileUtils.getFileUtils().resolveFile(getProject().getBaseDir(), s);
- }
- }
+ protected File resolveFile(final String s) {
+ if (getProject() == null) {
+ // Note FileUtils.getFileUtils replaces FileUtils.newFileUtils in Ant 1.6.3
+ return FileUtils.getFileUtils().resolveFile(null, s);
+ } else {
+ return FileUtils.getFileUtils().resolveFile(getProject().getBaseDir(), s);
+ }
+ }
private Reader openWebxmlReader(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
try {
- return webxmlEncoding != null ? new InputStreamReader(fis,
- webxmlEncoding) : new InputStreamReader(fis);
+ return webxmlEncoding != null ? new InputStreamReader(fis, webxmlEncoding) : new InputStreamReader(fis);
} catch (IOException ex) {
fis.close();
throw ex;
@@ -1812,8 +1762,7 @@ public class JspC extends Task implements Options {
private Writer openWebxmlWriter(File file) throws IOException {
FileOutputStream fos = new FileOutputStream(file);
try {
- return webxmlEncoding != null ? new OutputStreamWriter(fos,
- webxmlEncoding) : new OutputStreamWriter(fos);
+ return webxmlEncoding != null ? new OutputStreamWriter(fos, webxmlEncoding) : new OutputStreamWriter(fos);
} catch (IOException ex) {
fos.close();
throw ex;
diff --git a/java/org/apache/jasper/JspCompilationContext.java b/java/org/apache/jasper/JspCompilationContext.java
index d7c2ab2e50..bf04a4b9df 100644
--- a/java/org/apache/jasper/JspCompilationContext.java
+++ b/java/org/apache/jasper/JspCompilationContext.java
@@ -43,12 +43,9 @@ import org.apache.tomcat.Jar;
import org.apache.tomcat.util.descriptor.tld.TldResourcePath;
/**
- * A place holder for various things that are used through out the JSP
- * engine. This is a per-request/per-context data structure. Some of
- * the instance variables are set at different points.
- *
- * Most of the path-related stuff is here - mangling names, versions, dirs,
- * loading resources and dealing with uris.
+ * A place holder for various things that are used through out the JSP engine. This is a per-request/per-context data
+ * structure. Some of the instance variables are set at different points. Most of the path-related stuff is here -
+ * mangling names, versions, dirs, loading resources and dealing with uris.
*
* @author Anil K. Vijendran
* @author Harish Prabandham
@@ -94,21 +91,18 @@ public class JspCompilationContext {
private Jar tagJar;
// jspURI _must_ be relative to the context
- public JspCompilationContext(String jspUri, Options options,
- ServletContext context, JspServletWrapper jsw,
+ public JspCompilationContext(String jspUri, Options options, ServletContext context, JspServletWrapper jsw,
JspRuntimeContext rctxt) {
this(jspUri, null, options, context, jsw, rctxt, null, false);
}
- public JspCompilationContext(String tagfile, TagInfo tagInfo,
- Options options, ServletContext context, JspServletWrapper jsw,
- JspRuntimeContext rctxt, Jar tagJar) {
+ public JspCompilationContext(String tagfile, TagInfo tagInfo, Options options, ServletContext context,
+ JspServletWrapper jsw, JspRuntimeContext rctxt, Jar tagJar) {
this(tagfile, tagInfo, options, context, jsw, rctxt, tagJar, true);
}
- private JspCompilationContext(String jspUri, TagInfo tagInfo,
- Options options, ServletContext context, JspServletWrapper jsw,
- JspRuntimeContext rctxt, Jar tagJar, boolean isTagFile) {
+ private JspCompilationContext(String jspUri, TagInfo tagInfo, Options options, ServletContext context,
+ JspServletWrapper jsw, JspRuntimeContext rctxt, Jar tagJar, boolean isTagFile) {
this.jspUri = canonicalURI(jspUri);
this.options = options;
@@ -146,7 +140,7 @@ public class JspCompilationContext {
* @return the classpath that is passed off to the Java compiler.
*/
public String getClassPath() {
- if( classPath != null ) {
+ if (classPath != null) {
return classPath;
}
return rctxt.getClassPath();
@@ -154,6 +148,7 @@ public class JspCompilationContext {
/**
* The classpath that is passed off to the Java compiler.
+ *
* @param classPath The class path to use
*/
public void setClassPath(String classPath) {
@@ -161,12 +156,12 @@ public class JspCompilationContext {
}
/**
- * What class loader to use for loading classes while compiling
- * this JSP?
+ * What class loader to use for loading classes while compiling this JSP?
+ *
* @return the class loader used to load all compiled classes
*/
public ClassLoader getClassLoader() {
- if( loader != null ) {
+ if (loader != null) {
return loader;
}
return rctxt.getParentClassLoader();
@@ -177,9 +172,8 @@ public class JspCompilationContext {
}
public ClassLoader getJspLoader() {
- if( jspLoader == null ) {
- jspLoader = new JasperLoader(new URL[] {baseUrl}, getClassLoader(),
- rctxt.getPermissionCollection());
+ if (jspLoader == null) {
+ jspLoader = new JasperLoader(new URL[] { baseUrl }, getClassLoader(), rctxt.getPermissionCollection());
}
return jspLoader;
}
@@ -189,12 +183,12 @@ public class JspCompilationContext {
}
- // ---------- Input/Output ----------
+ // ---------- Input/Output ----------
/**
- * The output directory to generate code into. The output directory
- * is make up of the scratch directory, which is provide in Options,
- * plus the directory derived from the package name.
+ * The output directory to generate code into. The output directory is make up of the scratch directory, which is
+ * provide in Options, plus the directory derived from the package name.
+ *
* @return the output directory in which the generated sources are placed
*/
public String getOutputDir() {
@@ -206,13 +200,13 @@ public class JspCompilationContext {
}
/**
- * Create a "Compiler" object based on some init param data. This
- * is not done yet. Right now we're just hardcoding the actual
- * compilers that are created.
+ * Create a "Compiler" object based on some init param data. This is not done yet. Right now we're just hardcoding
+ * the actual compilers that are created.
+ *
* @return the Java compiler wrapper
*/
public Compiler createCompiler() {
- if (jspCompiler != null ) {
+ if (jspCompiler != null) {
return jspCompiler;
}
if (options.getCompilerClassName() != null) {
@@ -259,9 +253,10 @@ public class JspCompilationContext {
// ---------- Access resources in the webapp ----------
/**
- * Get the full value of a URI relative to this compilations context
- * uses current file as the base.
+ * Get the full value of a URI relative to this compilations context uses current file as the base.
+ *
* @param uri The relative URI
+ *
* @return absolute URI
*/
public String resolveRelativeUri(String uri) {
@@ -275,11 +270,11 @@ public class JspCompilationContext {
}
/**
- * Gets a resource as a stream, relative to the meanings of this
- * context's implementation.
+ * Gets a resource as a stream, relative to the meanings of this context's implementation.
+ *
* @param res the resource to look for
- * @return a null if the resource cannot be found or represented
- * as an InputStream.
+ *
+ * @return a null if the resource cannot be found or represented as an InputStream.
*/
public java.io.InputStream getResourceAsStream(String res) {
return context.getResourceAsStream(canonicalURI(res));
@@ -296,9 +291,10 @@ public class JspCompilationContext {
}
/**
- * Gets the actual path of a URI relative to the context of
- * the compilation.
+ * Gets the actual path of a URI relative to the context of the compilation.
+ *
* @param path The webapp path
+ *
* @return the corresponding path in the filesystem
*/
public String getRealPath(String path) {
@@ -309,10 +305,10 @@ public class JspCompilationContext {
}
/**
- * Returns the JAR file in which the tag file for which this
- * JspCompilationContext was created is packaged, or null if this
- * JspCompilationContext does not correspond to a tag file, or if the
- * corresponding tag file is not packaged in a JAR.
+ * Returns the JAR file in which the tag file for which this JspCompilationContext was created is packaged, or null
+ * if this JspCompilationContext does not correspond to a tag file, or if the corresponding tag file is not packaged
+ * in a JAR.
+ *
* @return a JAR file
*/
public Jar getTagFileJar() {
@@ -326,8 +322,8 @@ public class JspCompilationContext {
/* ==================== Common implementation ==================== */
/**
- * Just the class name (does not include package name) of the
- * generated class.
+ * Just the class name (does not include package name) of the generated class.
+ *
* @return the class name
*/
public String getServletClassName() {
@@ -354,8 +350,8 @@ public class JspCompilationContext {
}
/**
- * Path of the JSP URI. Note that this is not a file name. This is
- * the context rooted URI of the JSP file.
+ * Path of the JSP URI. Note that this is not a file name. This is the context rooted URI of the JSP file.
+ *
* @return the path to the JSP
*/
public String getJspFile() {
@@ -397,8 +393,7 @@ public class JspCompilationContext {
}
} catch (IOException e) {
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage(
- "jsp.error.lastModified", getJspFile()), e);
+ log.debug(Localizer.getMessage("jsp.error.lastModified", getJspFile()), e);
}
} finally {
if (uc != null) {
@@ -406,8 +401,7 @@ public class JspCompilationContext {
uc.getInputStream().close();
} catch (IOException e) {
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage(
- "jsp.error.lastModified", getJspFile()), e);
+ log.debug(Localizer.getMessage("jsp.error.lastModified", getJspFile()), e);
}
result = -1;
}
@@ -429,10 +423,8 @@ public class JspCompilationContext {
}
/**
- * @return <code>true</code> if we are compiling a tag file
- * in prototype mode.
- * ie we only generate codes with class for the tag handler with empty
- * method bodies.
+ * @return <code>true</code> if we are compiling a tag file in prototype mode. ie we only generate codes with class
+ * for the tag handler with empty method bodies.
*/
public boolean isPrototypeMode() {
return protoTypeMode;
@@ -443,9 +435,9 @@ public class JspCompilationContext {
}
/**
- * Package name for the generated class is made up of the base package
- * name, which is user settable, and the derived package name. The
- * derived package name directly mirrors the file hierarchy of the JSP page.
+ * Package name for the generated class is made up of the base package name, which is user settable, and the derived
+ * package name. The derived package name directly mirrors the file hierarchy of the JSP page.
+ *
* @return the package name
*/
public String getServletPackageName() {
@@ -469,15 +461,13 @@ public class JspCompilationContext {
protected String getDerivedPackageName() {
if (derivedPackageName == null) {
int iSep = jspUri.lastIndexOf('/');
- derivedPackageName = (iSep > 0) ?
- JspUtil.makeJavaPackage(jspUri.substring(1,iSep)) : "";
+ derivedPackageName = (iSep > 0) ? JspUtil.makeJavaPackage(jspUri.substring(1, iSep)) : "";
}
return derivedPackageName;
}
/**
- * @return The base package name into which all servlet and associated code
- * is generated
+ * @return The base package name into which all servlet and associated code is generated
*/
public String getBasePackageName() {
return basePackageName;
@@ -485,6 +475,7 @@ public class JspCompilationContext {
/**
* The package name into which the servlet class is generated.
+ *
* @param basePackageName The package name to use
*/
public void setBasePackageName(String basePackageName) {
@@ -492,8 +483,7 @@ public class JspCompilationContext {
}
/**
- * @return Full path name of the Java file into which the servlet is being
- * generated.
+ * @return Full path name of the Java file into which the servlet is being generated.
*/
public String getServletJavaFileName() {
if (servletJavaFileName == null) {
@@ -530,8 +520,7 @@ public class JspCompilationContext {
String tagName = tagInfo.getTagClassName();
javaPath = tagName.replace('.', '/') + ".java";
} else {
- javaPath = getServletPackageName().replace('.', '/') + '/' +
- getServletClassName() + ".java";
+ javaPath = getServletPackageName().replace('.', '/') + '/' + getServletClassName() + ".java";
}
return javaPath;
}
@@ -556,12 +545,13 @@ public class JspCompilationContext {
/**
* Gets the 'location' of the TLD associated with the given taglib 'uri'.
+ *
* @param uri The taglib URI
- * @return An array of two Strings: The first element denotes the real
- * path to the TLD. If the path to the TLD points to a jar file, then the
- * second element denotes the name of the TLD entry in the jar file.
- * Returns null if the given uri is not associated with any tag library
- * 'exposed' in the web application.
+ *
+ * @return An array of two Strings: The first element denotes the real path to the TLD. If the path to the TLD
+ * points to a jar file, then the second element denotes the name of the TLD entry in the jar file.
+ * Returns null if the given uri is not associated with any tag library 'exposed' in the web
+ * application.
*/
public TldResourcePath getTldResourcePath(String uri) {
return getOptions().getTldCache().getTldResourcePath(uri);
@@ -613,9 +603,7 @@ public class JspCompilationContext {
// Re-throw to let caller handle this - will result in a 404
throw fnfe;
} catch (Exception ex) {
- JasperException je = new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ JasperException je = new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
// Cache compilation exception
jsw.setCompilationException(je);
throw je;
@@ -632,11 +620,9 @@ public class JspCompilationContext {
String name = getFQCN();
servletClass = jspLoader.loadClass(name);
} catch (ClassNotFoundException cex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
- cex);
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.load"), cex);
} catch (Exception ex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
}
removed = false;
return servletClass;
@@ -667,7 +653,7 @@ public class JspCompilationContext {
}
protected boolean makeOutputDir() {
- synchronized(outputDirLock) {
+ synchronized (outputDirLock) {
File outDirFile = new File(outputDir);
return (outDirFile.mkdirs() || outDirFile.isDirectory());
}
@@ -680,7 +666,7 @@ public class JspCompilationContext {
path = tagName.replace('.', File.separatorChar);
path = path.substring(0, path.lastIndexOf(File.separatorChar));
} else {
- path = getServletPackageName().replace('.',File.separatorChar);
+ path = getServletPackageName().replace('.', File.separatorChar);
}
// Append servlet or tag handler path to scratch dir
@@ -710,52 +696,47 @@ public class JspCompilationContext {
int pos = 0;
while (pos < len) {
char c = s.charAt(pos);
- if ( isPathSeparator(c) ) {
+ if (isPathSeparator(c)) {
/*
- * multiple path separators.
- * 'foo///bar' -> 'foo/bar'
+ * multiple path separators. 'foo///bar' -> 'foo/bar'
*/
- while (pos+1 < len && isPathSeparator(s.charAt(pos+1))) {
+ while (pos + 1 < len && isPathSeparator(s.charAt(pos + 1))) {
++pos;
}
- if (pos+1 < len && s.charAt(pos+1) == '.') {
+ if (pos + 1 < len && s.charAt(pos + 1) == '.') {
/*
* a single dot at the end of the path - we are done.
*/
- if (pos+2 >= len) {
+ if (pos + 2 >= len) {
break;
}
- switch (s.charAt(pos+2)) {
+ switch (s.charAt(pos + 2)) {
/*
- * self directory in path
- * foo/./bar -> foo/bar
+ * self directory in path foo/./bar -> foo/bar
*/
case '/':
case '\\':
pos += 2;
continue;
- /*
- * two dots in a path: go back one hierarchy.
- * foo/bar/../baz -> foo/baz
- */
+ /*
+ * two dots in a path: go back one hierarchy. foo/bar/../baz -> foo/baz
+ */
case '.':
// only if we have exactly _two_ dots.
- if (pos+3 < len && isPathSeparator(s.charAt(pos+3))) {
+ if (pos + 3 < len && isPathSeparator(s.charAt(pos + 3))) {
pos += 3;
- int separatorPos = result.length()-1;
- while (separatorPos >= 0 &&
- ! isPathSeparator(result
- .charAt(separatorPos))) {
+ int separatorPos = result.length() - 1;
+ while (separatorPos >= 0 && !isPathSeparator(result.charAt(separatorPos))) {
--separatorPos;
}
if (separatorPos >= 0) {
result.setLength(separatorPos);
}
continue;
- }
+ }
}
}
}
diff --git a/java/org/apache/jasper/Options.java b/java/org/apache/jasper/Options.java
index 404fe35a24..16dd8c015d 100644
--- a/java/org/apache/jasper/Options.java
+++ b/java/org/apache/jasper/Options.java
@@ -35,9 +35,9 @@ import org.apache.jasper.compiler.TldCache;
public interface Options {
/**
- * Returns true if Jasper issues a compilation error instead of a runtime
- * Instantiation error if the class attribute specified in useBean action
- * is invalid.
+ * Returns true if Jasper issues a compilation error instead of a runtime Instantiation error if the class attribute
+ * specified in useBean action is invalid.
+ *
* @return <code>true</code> to get an error
*/
boolean getErrorOnUseBeanInvalidClassAttribute();
@@ -48,8 +48,7 @@ public interface Options {
boolean getKeepGenerated();
/**
- * @return <code>true</code> if tag handler pooling is enabled,
- * <code>false</code> otherwise.
+ * @return <code>true</code> if tag handler pooling is enabled, <code>false</code> otherwise.
*/
boolean isPoolingEnabled();
@@ -59,8 +58,7 @@ public interface Options {
boolean getMappedFile();
/**
- * @return <code>true</code> if debug information in included
- * in compiled classes.
+ * @return <code>true</code> if debug information in included in compiled classes.
*/
boolean getClassDebugInfo();
@@ -70,53 +68,48 @@ public interface Options {
int getCheckInterval();
/**
- * Main development flag, which enables detailed error reports with
- * sources, as well automatic recompilation of JSPs and tag files.
- * This setting should usually be <code>false</code> when running
- * in production.
+ * Main development flag, which enables detailed error reports with sources, as well automatic recompilation of JSPs
+ * and tag files. This setting should usually be <code>false</code> when running in production.
+ *
* @return <code>true</code> if Jasper is in development mode
*/
boolean getDevelopment();
/**
- * @return <code>true</code> to include a source fragment in exception
- * messages.
+ * @return <code>true</code> to include a source fragment in exception messages.
*/
boolean getDisplaySourceFragment();
/**
- * @return <code>true</code> to suppress generation of SMAP info for
- * JSR45 debugging.
+ * @return <code>true</code> to suppress generation of SMAP info for JSR45 debugging.
*/
boolean isSmapSuppressed();
/**
* This setting is ignored if suppressSmap() is <code>true</code>.
- * @return <code>true</code> to write SMAP info for JSR45 debugging to a
- * file.
+ *
+ * @return <code>true</code> to write SMAP info for JSR45 debugging to a file.
*/
boolean isSmapDumped();
/**
- * @return {@link TrimSpacesOption#TRUE} to remove template text that
- * consists only of whitespace from the output completely,
- * {@link TrimSpacesOption#SINGLE} to replace such template text
- * with a single space, {@link TrimSpacesOption#FALSE} to leave
- * such template text unchanged or {@link TrimSpacesOption#EXTENDED}
- * to remove template text that consists only of whitespace and to
- * replace any sequence of whitespace and new lines within template
- * text with a single new line.
+ * @return {@link TrimSpacesOption#TRUE} to remove template text that consists only of whitespace from the output
+ * completely, {@link TrimSpacesOption#SINGLE} to replace such template text with a single space,
+ * {@link TrimSpacesOption#FALSE} to leave such template text unchanged or
+ * {@link TrimSpacesOption#EXTENDED} to remove template text that consists only of whitespace and to
+ * replace any sequence of whitespace and new lines within template text with a single new line.
*/
TrimSpacesOption getTrimSpaces();
/**
- * Gets the class-id value that is sent to Internet Explorer when using
- * <jsp:plugin> tags.
+ * Gets the class-id value that is sent to Internet Explorer when using <jsp:plugin> tags.
+ *
* @return Class-id value
*
* @deprecated Will be removed in Tomcat 10.1.x
*/
- @Deprecated String getIeClassId();
+ @Deprecated
+ String getIeClassId();
/**
* @return the work folder
@@ -130,13 +123,11 @@ public interface Options {
/**
* Compiler to use.
- *
* <p>
- * If <code>null</code> (the default), the java compiler from Eclipse JDT
- * project, bundled with Tomcat, will be used. Otherwise, the
- * <code>javac</code> task from Apache Ant will be used to call an external
- * java compiler and the value of this option will be passed to it. See
- * Apache Ant documentation for the possible values.
+ * If <code>null</code> (the default), the java compiler from Eclipse JDT project, bundled with Tomcat, will be
+ * used. Otherwise, the <code>javac</code> task from Apache Ant will be used to call an external java compiler and
+ * the value of this option will be passed to it. See Apache Ant documentation for the possible values.
+ *
* @return the compiler name
*/
String getCompiler();
@@ -157,14 +148,11 @@ public interface Options {
String getCompilerClassName();
/**
- * The cache that maps URIs, resource paths and parsed TLD files for the
- * various tag libraries 'exposed' by the web application.
- * A tag library is 'exposed' either explicitly in
- * web.xml or implicitly via the uri tag in the TLD
- * of a taglib deployed in a jar file (WEB-INF/lib).
+ * The cache that maps URIs, resource paths and parsed TLD files for the various tag libraries 'exposed' by the web
+ * application. A tag library is 'exposed' either explicitly in web.xml or implicitly via the uri tag in the TLD of
+ * a taglib deployed in a jar file (WEB-INF/lib).
*
- * @return the instance of the TldCache
- * for the web-application.
+ * @return the instance of the TldCache for the web-application.
*/
TldCache getTldCache();
@@ -175,10 +163,9 @@ public interface Options {
/**
* The boolean flag to tell Ant whether to fork JSP page compilations.
- *
* <p>
- * Is used only when Jasper uses an external java compiler (wrapped through
- * a <code>javac</code> Apache Ant task).
+ * Is used only when Jasper uses an external java compiler (wrapped through a <code>javac</code> Apache Ant task).
+ *
* @return <code>true</code> to fork a process during compilation
*/
boolean getFork();
@@ -201,8 +188,7 @@ public interface Options {
/**
* Indicates whether text strings are to be generated as char arrays.
*
- * @return <code>true</code> if text strings are to be generated as char
- * arrays, <code>false</code> otherwise
+ * @return <code>true</code> if text strings are to be generated as char arrays, <code>false</code> otherwise
*/
boolean genStringAsCharArray();
@@ -218,54 +204,51 @@ public interface Options {
boolean getRecompileOnFail();
/**
- * @return <code>true</code> is caching is enabled
- * (used for precompilation).
+ * @return <code>true</code> is caching is enabled (used for precompilation).
*/
boolean isCaching();
/**
- * The web-application wide cache for the TagLibraryInfo tag library
- * descriptors, used if {@link #isCaching()} returns <code>true</code>.
- *
+ * The web-application wide cache for the TagLibraryInfo tag library descriptors, used if {@link #isCaching()}
+ * returns <code>true</code>.
* <p>
- * Using this cache avoids the cost of repeating the parsing of a tag
- * library descriptor XML file (performed by TagLibraryInfoImpl.parseTLD).
+ * Using this cache avoids the cost of repeating the parsing of a tag library descriptor XML file (performed by
+ * TagLibraryInfoImpl.parseTLD).
* </p>
*
* @return the Map(String uri, TagLibraryInfo tld) instance.
*/
- Map<String, TagLibraryInfo> getCache();
+ Map<String,TagLibraryInfo> getCache();
/**
- * The maximum number of loaded jsps per web-application. If there are more
- * jsps loaded, they will be unloaded. If unset or less than 0, no jsps
- * are unloaded.
+ * The maximum number of loaded jsps per web-application. If there are more jsps loaded, they will be unloaded. If
+ * unset or less than 0, no jsps are unloaded.
+ *
* @return The JSP count
*/
int getMaxLoadedJsps();
/**
- * @return the idle time in seconds after which a JSP is unloaded.
- * If unset or less or equal than 0, no jsps are unloaded.
+ * @return the idle time in seconds after which a JSP is unloaded. If unset or less or equal than 0, no jsps are
+ * unloaded.
*/
int getJspIdleTimeout();
/**
- * @return {@code true} if the quote escaping required by section JSP.1.6 of
- * the JSP specification should be applied to scriplet expression.
+ * @return {@code true} if the quote escaping required by section JSP.1.6 of the JSP specification should be applied
+ * to scriplet expression.
*/
boolean getStrictQuoteEscaping();
/**
- * @return {@code true} if EL expressions used within attributes should have
- * the quoting rules in JSP.1.6 applied to the expression.
+ * @return {@code true} if EL expressions used within attributes should have the quoting rules in JSP.1.6 applied to
+ * the expression.
*/
boolean getQuoteAttributeEL();
/**
- * Should the container include the time the file was generated in the
- * comments at the start of a Java file generated from a JSP or tag.
- * Defaults to {@code true}.
+ * Should the container include the time the file was generated in the comments at the start of a Java file
+ * generated from a JSP or tag. Defaults to {@code true}.
*
* @return {@code true} to include the timestamp, otherwise don't include it
*/
diff --git a/java/org/apache/jasper/tagplugins/jstl/Util.java b/java/org/apache/jasper/tagplugins/jstl/Util.java
index aeecc01a04..40f8226a60 100644
--- a/java/org/apache/jasper/tagplugins/jstl/Util.java
+++ b/java/org/apache/jasper/tagplugins/jstl/Util.java
@@ -36,22 +36,18 @@ import org.apache.jasper.Constants;
import org.apache.jasper.compiler.Localizer;
/**
- * Util contains some often used consts, static methods and embedded class
- * to support the JSTL tag plugin.
+ * Util contains some often used consts, static methods and embedded class to support the JSTL tag plugin.
*/
public class Util {
- private static final String VALID_SCHEME_CHAR =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
+ private static final String VALID_SCHEME_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
- public static final String DEFAULT_ENCODING =
- "ISO-8859-1";
+ public static final String DEFAULT_ENCODING = "ISO-8859-1";
private static final int HIGHEST_SPECIAL = '>';
- private static final char[][] specialCharactersRepresentation =
- new char[HIGHEST_SPECIAL + 1][];
+ private static final char[][] specialCharactersRepresentation = new char[HIGHEST_SPECIAL + 1][];
static {
specialCharactersRepresentation['&'] = "&".toCharArray();
@@ -62,26 +58,22 @@ public class Util {
}
/**
- * Converts the given string description of a scope to the corresponding
- * PageContext constant.
- *
- * The validity of the given scope has already been checked by the
- * appropriate TLV.
+ * Converts the given string description of a scope to the corresponding PageContext constant. The validity of the
+ * given scope has already been checked by the appropriate TLV.
*
* @param scope String description of scope
*
- * @return PageContext constant corresponding to given scope description
- *
- * taken from org.apache.taglibs.standard.tag.common.core.Util
+ * @return PageContext constant corresponding to given scope description taken from
+ * org.apache.taglibs.standard.tag.common.core.Util
*/
- public static int getScope(String scope){
+ public static int getScope(String scope) {
int ret = PageContext.PAGE_SCOPE;
- if("request".equalsIgnoreCase(scope)){
+ if ("request".equalsIgnoreCase(scope)) {
ret = PageContext.REQUEST_SCOPE;
- }else if("session".equalsIgnoreCase(scope)){
+ } else if ("session".equalsIgnoreCase(scope)) {
ret = PageContext.SESSION_SCOPE;
- }else if("application".equalsIgnoreCase(scope)){
+ } else if ("application".equalsIgnoreCase(scope)) {
ret = PageContext.APPLICATION_SCOPE;
}
@@ -89,24 +81,25 @@ public class Util {
}
/**
- * Returns <code>true</code> if our current URL is absolute,
- * <code>false</code> otherwise.
- * taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
+ * Returns <code>true</code> if our current URL is absolute, <code>false</code> otherwise. taken from
+ * org.apache.taglibs.standard.tag.common.core.ImportSupport
+ *
* @param url The URL
+ *
* @return <code>true</code> if the URL is absolute
*/
- public static boolean isAbsoluteUrl(String url){
- if(url == null){
+ public static boolean isAbsoluteUrl(String url) {
+ if (url == null) {
return false;
}
int colonPos = url.indexOf(':');
- if(colonPos == -1){
+ if (colonPos == -1) {
return false;
}
- for(int i=0;i<colonPos;i++){
- if(VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1){
+ for (int i = 0; i < colonPos; i++) {
+ if (VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1) {
return false;
}
}
@@ -115,11 +108,12 @@ public class Util {
}
/**
- * Get the value associated with a content-type attribute.
- * Syntax defined in RFC 2045, section 5.1.
- * taken from org.apache.taglibs.standard.tag.common.core.Util
+ * Get the value associated with a content-type attribute. Syntax defined in RFC 2045, section 5.1. taken from
+ * org.apache.taglibs.standard.tag.common.core.Util
+ *
* @param input The attribute string
- * @param name The attribute name
+ * @param name The attribute name
+ *
* @return the attribute value
*/
public static String getContentTypeAttribute(String input, String name) {
@@ -158,13 +152,12 @@ public class Util {
}
/**
- * Strips a servlet session ID from <code>url</code>. The session ID
- * is encoded as a URL "path parameter" beginning with "jsessionid=".
- * We thus remove anything we find between ";jsessionid=" (inclusive)
- * and either EOS or a subsequent ';' (exclusive).
+ * Strips a servlet session ID from <code>url</code>. The session ID is encoded as a URL "path parameter" beginning
+ * with "jsessionid=". We thus remove anything we find between ";jsessionid=" (inclusive) and either EOS or a
+ * subsequent ';' (exclusive). taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
*
- * taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
* @param url The URL
+ *
* @return the URL without a user submitted session id parameter
*/
public static String stripSession(String url) {
@@ -185,19 +178,18 @@ public class Util {
/**
- * Performs the following substring replacements
- * (to facilitate output to XML/HTML pages):
+ * Performs the following substring replacements (to facilitate output to XML/HTML pages):
* <ul>
- * <li>{@code &} -> {@code &}</li>
- * <li>{@code <} -> {@code <}</li>
- * <li>{@code >} -> {@code >}</li>
- * <li>{@code "} -> {@code "}</li>
- * <li>{@code '} -> {@code '}</li>
+ * <li>{@code &} -> {@code &}</li>
+ * <li>{@code <} -> {@code <}</li>
+ * <li>{@code >} -> {@code >}</li>
+ * <li>{@code "} -> {@code "}</li>
+ * <li>{@code '} -> {@code '}</li>
* </ul>
- * See also OutSupport.writeEscapedXml().
+ * See also OutSupport.writeEscapedXml(). taken from org.apache.taglibs.standard.tag.common.core.Util
*
- * taken from org.apache.taglibs.standard.tag.common.core.Util
* @param buffer Data to escape
+ *
* @return escaped data
*/
public static String escapeXml(String buffer) {
@@ -225,7 +217,7 @@ public class Util {
}
// add unescaped portion
if (start < i) {
- escapedBuffer.append(arrayBuffer,start,i-start);
+ escapedBuffer.append(arrayBuffer, start, i - start);
}
start = i + 1;
// add escaped xml
@@ -239,31 +231,30 @@ public class Util {
}
// add rest of unescaped portion
if (start < length) {
- escapedBuffer.append(arrayBuffer,start,length-start);
+ escapedBuffer.append(arrayBuffer, start, length - start);
}
return escapedBuffer.toString();
}
/**
- * Utility methods
- * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
- * @param url The URL
- * @param context The context
+ * Utility methods taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
+ *
+ * @param url The URL
+ * @param context The context
* @param pageContext The page context
+ *
* @return the absolute URL
+ *
* @throws JspException If the URL doesn't start with '/'
*/
- public static String resolveUrl(
- String url, String context, PageContext pageContext)
- throws JspException {
+ public static String resolveUrl(String url, String context, PageContext pageContext) throws JspException {
// don't touch absolute URLs
if (isAbsoluteUrl(url)) {
return url;
}
// normalize relative URLs against a context root
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
+ HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
if (context == null) {
if (url.startsWith("/")) {
return request.getContextPath() + url;
@@ -286,10 +277,10 @@ public class Util {
}
/**
- * Wraps responses to allow us to retrieve results as Strings. Mainly taken
- * from org.apache.taglibs.standard.tag.common.core.importSupport.
+ * Wraps responses to allow us to retrieve results as Strings. Mainly taken from
+ * org.apache.taglibs.standard.tag.common.core.importSupport.
*/
- public static class ImportResponseWrapper extends HttpServletResponseWrapper{
+ public static class ImportResponseWrapper extends HttpServletResponseWrapper {
private final StringWriter sw = new StringWriter();
private final ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -312,7 +303,6 @@ public class Util {
}
-
};
private boolean isWriterUsed;
private boolean isStreamUsed;
@@ -361,11 +351,11 @@ public class Util {
return status;
}
- public String getCharEncoding(){
+ public String getCharEncoding() {
return this.charEncoding;
}
- public void setCharEncoding(String ce){
+ public void setCharEncoding(String ce) {
this.charEncoding = ce;
}
@@ -378,8 +368,7 @@ public class Util {
} else {
return bos.toString("ISO-8859-1");
}
- }
- else {
+ } else {
return ""; // target didn't write anything
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
index a51af3025d..5eeee41d43 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
@@ -24,41 +24,41 @@ public class Catch implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //flag for the existence of the var attribute
+ // flag for the existence of the var attribute
boolean hasVar = ctxt.isAttributeSpecified("var");
- //temp name for exception and caught
+ // temp name for exception and caught
String exceptionName = ctxt.getTemporaryVariableName();
String caughtName = ctxt.getTemporaryVariableName();
- //main part to generate code
+ // main part to generate code
ctxt.generateJavaSource("boolean " + caughtName + " = false;");
ctxt.generateJavaSource("try{");
ctxt.generateBody();
ctxt.generateJavaSource("}");
- //do catch
+ // do catch
ctxt.generateJavaSource("catch(Throwable " + exceptionName + "){");
- //if the var specified, the exception object should
- //be set to the attribute "var" defines in page scope
- if(hasVar){
+ // if the var specified, the exception object should
+ // be set to the attribute "var" defines in page scope
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", "
- + exceptionName + ", PageContext.PAGE_SCOPE);");
+ ctxt.generateJavaSource(
+ " pageContext.setAttribute(\"" + strVar + "\", " + exceptionName + ", PageContext.PAGE_SCOPE);");
}
- //whenever there's exception caught,
- //the flag caught should be set true;
+ // whenever there's exception caught,
+ // the flag caught should be set true;
ctxt.generateJavaSource(" " + caughtName + " = true;");
ctxt.generateJavaSource("}");
- //do finally
+ // do finally
ctxt.generateJavaSource("finally{");
- //if var specified, the attribute it defines
- //in page scope should be removed
- if(hasVar){
+ // if var specified, the attribute it defines
+ // in page scope should be removed
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(" if(!" + caughtName + "){");
ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\", PageContext.PAGE_SCOPE);");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
index 19bdede07e..b3d318f034 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
@@ -71,8 +71,7 @@ public final class ForEach implements TagPlugin {
}
/**
- * Generate codes for Collections
- * The pseudo code is:
+ * Generate codes for Collections The pseudo code is:
*/
private void doCollection(TagPluginContext ctxt) {
@@ -84,7 +83,7 @@ public final class ForEach implements TagPlugin {
ctxt.generateAttribute("items");
ctxt.generateJavaSource(";");
- String indexV=null, beginV=null, endV=null, stepV=null;
+ String indexV = null, beginV = null, endV = null, stepV = null;
if (hasBegin) {
beginV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("int " + beginV + " = ");
@@ -161,9 +160,8 @@ public final class ForEach implements TagPlugin {
if (hasBegin) {
String tV = ctxt.getTemporaryVariableName();
- ctxt.generateJavaSource("for (int " + tV + "=" + beginV + ";" +
- tV + ">0 && " + iterV + ".hasNext(); " +
- tV + "--)");
+ ctxt.generateJavaSource(
+ "for (int " + tV + "=" + beginV + ";" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)");
ctxt.generateJavaSource(iterV + ".next();");
}
@@ -178,9 +176,8 @@ public final class ForEach implements TagPlugin {
if (hasStep) {
String tV = ctxt.getTemporaryVariableName();
- ctxt.generateJavaSource("for (int " + tV + "=" + stepV + "-1;" +
- tV + ">0 && " + iterV + ".hasNext(); " +
- tV + "--)");
+ ctxt.generateJavaSource(
+ "for (int " + tV + "=" + stepV + "-1;" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)");
ctxt.generateJavaSource(iterV + ".next();");
}
if (hasEnd) {
@@ -190,8 +187,7 @@ public final class ForEach implements TagPlugin {
ctxt.generateJavaSource(indexV + "++;");
}
if (hasBegin) {
- ctxt.generateJavaSource("if(" + beginV + "+" + indexV +
- ">"+ endV + ")");
+ ctxt.generateJavaSource("if(" + beginV + "+" + indexV + ">" + endV + ")");
} else {
ctxt.generateJavaSource("if(" + indexV + ">" + endV + ")");
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
index c4e1cabf94..2e37b08e70 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
@@ -25,60 +25,61 @@ public class ForTokens implements TagPlugin {
public void doTag(TagPluginContext ctxt) {
boolean hasVar, hasVarStatus, hasBegin, hasEnd, hasStep;
- //init the flags
+ // init the flags
hasVar = ctxt.isAttributeSpecified("var");
hasVarStatus = ctxt.isAttributeSpecified("varStatus");
hasBegin = ctxt.isAttributeSpecified("begin");
hasEnd = ctxt.isAttributeSpecified("end");
hasStep = ctxt.isAttributeSpecified("step");
- if(hasVarStatus){
+ if (hasVarStatus) {
ctxt.dontUseTagPlugin();
return;
}
- //define all the temp variables' names
+ // define all the temp variables' names
String itemsName = ctxt.getTemporaryVariableName();
String delimsName = ctxt.getTemporaryVariableName();
String stName = ctxt.getTemporaryVariableName();
String beginName = ctxt.getTemporaryVariableName();
- String endName = ctxt.getTemporaryVariableName();
+ String endName = ctxt.getTemporaryVariableName();
String stepName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
- String temp = ctxt.getTemporaryVariableName();
+ String temp = ctxt.getTemporaryVariableName();
String tokensCountName = ctxt.getTemporaryVariableName();
- //get the value of the "items" attribute
+ // get the value of the "items" attribute
ctxt.generateJavaSource("String " + itemsName + " = (String)");
ctxt.generateAttribute("items");
ctxt.generateJavaSource(";");
- //get the value of the "delim" attribute
+ // get the value of the "delim" attribute
ctxt.generateJavaSource("String " + delimsName + " = (String)");
ctxt.generateAttribute("delims");
ctxt.generateJavaSource(";");
- //new a StringTokenizer Object according to the "items" and the "delim"
- ctxt.generateJavaSource("java.util.StringTokenizer " + stName + " = " +
- "new java.util.StringTokenizer(" + itemsName + ", " + delimsName + ");");
+ // new a StringTokenizer Object according to the "items" and the "delim"
+ ctxt.generateJavaSource("java.util.StringTokenizer " + stName + " = " + "new java.util.StringTokenizer(" +
+ itemsName + ", " + delimsName + ");");
- //if "begin" specified, move the token to the "begin" place
- //and record the begin index. default begin place is 0.
+ // if "begin" specified, move the token to the "begin" place
+ // and record the begin index. default begin place is 0.
ctxt.generateJavaSource("int " + tokensCountName + " = " + stName + ".countTokens();");
- if(hasBegin){
- ctxt.generateJavaSource("int " + beginName + " = " );
+ if (hasBegin) {
+ ctxt.generateJavaSource("int " + beginName + " = ");
ctxt.generateAttribute("begin");
ctxt.generateJavaSource(";");
- ctxt.generateJavaSource("for(int " + index + " = 0; " + index + " < " + beginName + " && " + stName + ".hasMoreTokens(); " + index + "++, " + stName + ".nextToken()){}");
- }else{
+ ctxt.generateJavaSource("for(int " + index + " = 0; " + index + " < " + beginName + " && " + stName +
+ ".hasMoreTokens(); " + index + "++, " + stName + ".nextToken()){}");
+ } else {
ctxt.generateJavaSource("int " + beginName + " = 0;");
}
- //when "end" is specified, if the "end" is more than the last index,
- //record the end place as the last index, otherwise, record it as "end";
- //default end place is the last index
- if(hasEnd){
- ctxt.generateJavaSource("int " + endName + " = 0;" );
+ // when "end" is specified, if the "end" is more than the last index,
+ // record the end place as the last index, otherwise, record it as "end";
+ // default end place is the last index
+ if (hasEnd) {
+ ctxt.generateJavaSource("int " + endName + " = 0;");
ctxt.generateJavaSource("if((" + tokensCountName + " - 1) < ");
ctxt.generateAttribute("end");
ctxt.generateJavaSource("){");
@@ -87,26 +88,27 @@ public class ForTokens implements TagPlugin {
ctxt.generateJavaSource(" " + endName + " = ");
ctxt.generateAttribute("end");
ctxt.generateJavaSource(";}");
- }else{
+ } else {
ctxt.generateJavaSource("int " + endName + " = " + tokensCountName + " - 1;");
}
- //get the step value from "step" if specified.
- //default step value is 1.
- if(hasStep){
- ctxt.generateJavaSource("int " + stepName + " = " );
+ // get the step value from "step" if specified.
+ // default step value is 1.
+ if (hasStep) {
+ ctxt.generateJavaSource("int " + stepName + " = ");
ctxt.generateAttribute("step");
ctxt.generateJavaSource(";");
- }else{
+ } else {
ctxt.generateJavaSource("int " + stepName + " = 1;");
}
- //the loop
- ctxt.generateJavaSource("for(int " + index + " = " + beginName + "; " + index + " <= " + endName + "; " + index + "++){");
+ // the loop
+ ctxt.generateJavaSource(
+ "for(int " + index + " = " + beginName + "; " + index + " <= " + endName + "; " + index + "++){");
ctxt.generateJavaSource(" String " + temp + " = " + stName + ".nextToken();");
ctxt.generateJavaSource(" if(((" + index + " - " + beginName + ") % " + stepName + ") == 0){");
- //if var specified, put the current token into the attribute "var" defines.
- if(hasVar){
+ // if var specified, put the current token into the attribute "var" defines.
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", " + temp + ");");
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Import.java b/java/org/apache/jasper/tagplugins/jstl/core/Import.java
index aea45c0683..5e9097f38b 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Import.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Import.java
@@ -26,19 +26,19 @@ public class Import implements TagPlugin {
public void doTag(TagPluginContext ctxt) {
boolean hasContext, hasVar, hasScope, hasVarReader, hasCharEncoding;
- //flags
- hasContext = ctxt.isAttributeSpecified("context");
+ // flags
+ hasContext = ctxt.isAttributeSpecified("context");
hasVar = ctxt.isAttributeSpecified("var");
hasScope = ctxt.isAttributeSpecified("scope");
hasVarReader = ctxt.isAttributeSpecified("varReader");
hasCharEncoding = ctxt.isAttributeSpecified("charEncoding");
- //variables' names
+ // variables' names
String urlName = ctxt.getTemporaryVariableName();
String contextName = ctxt.getTemporaryVariableName();
- String iauName = ctxt.getTemporaryVariableName(); // is absolute url
- String urlObjName = ctxt.getTemporaryVariableName(); //URL object
- String ucName = ctxt.getTemporaryVariableName(); //URLConnection
+ String iauName = ctxt.getTemporaryVariableName(); // is absolute url
+ String urlObjName = ctxt.getTemporaryVariableName(); // URL object
+ String ucName = ctxt.getTemporaryVariableName(); // URLConnection
String inputStreamName = ctxt.getTemporaryVariableName();
String tempReaderName = ctxt.getTemporaryVariableName();
String tempReaderName2 = ctxt.getTemporaryVariableName();
@@ -49,172 +49,187 @@ public class Import implements TagPlugin {
String servletContextName = ctxt.getTemporaryVariableName();
String servletPathName = ctxt.getTemporaryVariableName();
String requestDispatcherName = ctxt.getTemporaryVariableName();
- String irwName = ctxt.getTemporaryVariableName(); //ImportResponseWrapper name
- String brName = ctxt.getTemporaryVariableName(); //BufferedReader name
- String sbName = ctxt.getTemporaryVariableName(); //StringBuilder name
+ String irwName = ctxt.getTemporaryVariableName(); // ImportResponseWrapper name
+ String brName = ctxt.getTemporaryVariableName(); // BufferedReader name
+ String sbName = ctxt.getTemporaryVariableName(); // StringBuilder name
String tempStringName = ctxt.getTemporaryVariableName();
- //is absolute url
+ // is absolute url
ctxt.generateJavaSource("boolean " + iauName + ";");
- //get the url value
+ // get the url value
ctxt.generateJavaSource("String " + urlName + " = ");
ctxt.generateAttribute("url");
ctxt.generateJavaSource(";");
- //validate the url
+ // validate the url
ctxt.generateJavaSource("if(" + urlName + " == null || " + urlName + ".equals(\"\")){");
ctxt.generateJavaSource(" throw new JspTagException(\"The \\\"url\\\" attribute " +
- "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");");
+ "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");");
ctxt.generateJavaSource("}");
- //initialize the is_absolute_url
- ctxt.generateJavaSource(iauName + " = " +
- "org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");");
+ // initialize the is_absolute_url
+ ctxt.generateJavaSource(
+ iauName + " = " + "org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");");
- //validate the context
- if(hasContext){
+ // validate the context
+ if (hasContext) {
ctxt.generateJavaSource("String " + contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
- ctxt.generateJavaSource("if((!" + contextName + ".startsWith(\"/\")) " +
- "|| (!" + urlName + ".startsWith(\"/\"))){");
+ ctxt.generateJavaSource(
+ "if((!" + contextName + ".startsWith(\"/\")) " + "|| (!" + urlName + ".startsWith(\"/\"))){");
ctxt.generateJavaSource(" throw new JspTagException" +
"(\"In URL tags, when the \\\"context\\\" attribute is specified, " +
- "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");");
+ "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");");
ctxt.generateJavaSource("}");
}
- //define charset
+ // define charset
ctxt.generateJavaSource("String " + charSetName + " = null;");
- //if the charEncoding attribute is specified
- if(hasCharEncoding){
+ // if the charEncoding attribute is specified
+ if (hasCharEncoding) {
- //initialize the charEncoding
+ // initialize the charEncoding
ctxt.generateJavaSource("String " + charEncodingName + " = ");
ctxt.generateAttribute("charEncoding");
ctxt.generateJavaSource(";");
- //assign appropriate value to the charset
- ctxt.generateJavaSource("if(null != " + charEncodingName + " " +
- "&& !" + charEncodingName + ".equals(\"\")){");
- ctxt.generateJavaSource(" " + charSetName + " = "
- + charEncodingName + ";");
+ // assign appropriate value to the charset
+ ctxt.generateJavaSource(
+ "if(null != " + charEncodingName + " " + "&& !" + charEncodingName + ".equals(\"\")){");
+ ctxt.generateJavaSource(" " + charSetName + " = " + charEncodingName + ";");
ctxt.generateJavaSource("}");
}
- //reshape the url string
- ctxt.generateJavaSource("if(!"+iauName+"){");
+ // reshape the url string
+ ctxt.generateJavaSource("if(!" + iauName + "){");
ctxt.generateJavaSource(" if(!" + urlName + ".startsWith(\"/\")){");
ctxt.generateJavaSource(" String " + servletPathName + " = " +
- "((HttpServletRequest)pageContext.getRequest()).getServletPath();");
- ctxt.generateJavaSource(" " + urlName + " = "
- + servletPathName + ".substring(0," + servletPathName + ".lastIndexOf('/')) + '/' + " + urlName + ";");
+ "((HttpServletRequest)pageContext.getRequest()).getServletPath();");
+ ctxt.generateJavaSource(" " + urlName + " = " + servletPathName + ".substring(0," + servletPathName +
+ ".lastIndexOf('/')) + '/' + " + urlName + ";");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource("}");
- //if the varReader attribute specified
- if(hasVarReader){
+ // if the varReader attribute specified
+ if (hasVarReader) {
- //get the String value of varReader
+ // get the String value of varReader
ctxt.generateJavaSource("String " + varReaderName + " = ");
ctxt.generateAttribute("varReader");
ctxt.generateJavaSource(";");
- //if the url is absolute url
+ // if the url is absolute url
ctxt.generateJavaSource("if(" + iauName + "){");
- //get the content of the target
+ // get the content of the target
ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
- ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = "
- + urlObjName + ".openConnection();");
- ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = "
- + ucName + ".getInputStream();");
+ ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();");
+ ctxt.generateJavaSource(
+ " java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" String " + contentTypeName + " = "
- + ucName + ".getContentType();");
+ ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();");
ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
ctxt.generateJavaSource(" " + charSetName + " = " +
- "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
- ctxt.generateJavaSource(" if(" + charSetName + " == null) "
- + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName +
+ ", \"charset\");");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) " + charSetName +
+ " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(
+ " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
- if(!hasCharEncoding){
+ if (!hasCharEncoding) {
ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();");
}
- //define the Reader
+ // define the Reader
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
- //initialize the Reader object
+ // initialize the Reader object
ctxt.generateJavaSource(" try{");
- ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", " + charSetName + ");");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" +
+ inputStreamName + ", " + charSetName + ");");
ctxt.generateJavaSource(" }catch(Exception ex){");
- ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" +
+ inputStreamName + ", org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
ctxt.generateJavaSource(" }");
- //validate the response
+ // validate the response
ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
- ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
+ ctxt.generateJavaSource(
+ " int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
ctxt.generateJavaSource(" if(status < 200 || status > 299){");
ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
- //set attribute in the page context scope
+ // set attribute in the page context scope
ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
- //if the url is relative
+ // if the url is relative
ctxt.generateJavaSource("}else{");
- //if the url is relative, http request is needed
+ // if the url is relative, http request is needed
ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof HttpServletResponse)){");
- ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
- //get the servlet context of the context defined in the context attribute
+ // get the servlet context of the context defined in the context attribute
ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName + "){");
- ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" " + servletContextName +
+ " = pageContext.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
ctxt.generateJavaSource(" }");
- }else{
+ } else {
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
}
//
ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
- if(hasContext){
- ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" + contextName + "+\" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
- }else{
- ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ if (hasContext) {
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" +
+ contextName + "+\" \\\" and URL: \\\" \" +" + urlName +
+ "+ \" \\\". Verify values and/or enable cross context access.\");");
+ } else {
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" +
+ urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
}
ctxt.generateJavaSource(" }");
- //get the request dispatcher
- ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
- ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+ // get the request dispatcher
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName +
+ ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName +
+ " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession(" +
+ urlName + "));");
- //initialize a ImportResponseWrapper to include the resource
- ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
+ // initialize a ImportResponseWrapper to include the resource
+ ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName +
+ " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(
+ " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");");
ctxt.generateJavaSource(" try{");
- ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
+ ctxt.generateJavaSource(
+ " " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
ctxt.generateJavaSource(" throw new JspException(ex);");
ctxt.generateJavaSource(" }catch(RuntimeException ex){");
@@ -227,35 +242,38 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource(" throw new JspException(rc);");
ctxt.generateJavaSource(" }");
- //validate the response status
+ // validate the response status
ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
- ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" throw new JspTagException(" + irwName +
+ ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
ctxt.generateJavaSource(" }");
- //push in the page context
- ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName + ".getString());");
+ // push in the page context
+ ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName +
+ ".getString());");
ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
ctxt.generateJavaSource("}");
- //execute the body action
+ // execute the body action
ctxt.generateBody();
- //close the reader
- ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 + " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");");
+ // close the reader
+ ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 +
+ " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");");
ctxt.generateJavaSource("if(" + tempReaderName2 + " != null) " + tempReaderName2 + ".close();");
ctxt.generateJavaSource("pageContext.removeAttribute(" + varReaderName + ",1);");
}
- //if the varReader is not specified
- else{
+ // if the varReader is not specified
+ else {
ctxt.generateJavaSource("pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
ctxt.generateBody();
ctxt.generateJavaSource(urlName + " = (String)pageContext.getAttribute(\"url_without_param\");");
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
String strScope = "page";
- if(hasScope){
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
}
int iScope = Util.getScope(strScope);
@@ -264,88 +282,108 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource("if(" + iauName + "){");
- //get the content of the target
+ // get the content of the target
ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();");
- ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();");
+ ctxt.generateJavaSource(
+ " java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();");
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" String " + contentTypeName + " = "
- + ucName + ".getContentType();");
+ ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();");
ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
ctxt.generateJavaSource(" " + charSetName + " = " +
- "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
- ctxt.generateJavaSource(" if(" + charSetName + " == null) "
- + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName +
+ ", \"charset\");");
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) " + charSetName +
+ " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(
+ " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" try{");
- ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + "," + charSetName + ");");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" +
+ inputStreamName + "," + charSetName + ");");
ctxt.generateJavaSource(" }catch(Exception ex){");
- //ctxt.generateJavaSource(" throw new JspTagException(ex.toString());");
- ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ",org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
+ // ctxt.generateJavaSource(" throw new JspTagException(ex.toString());");
+ ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" +
+ inputStreamName + ",org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
ctxt.generateJavaSource(" }");
- //validate the response
+ // validate the response
ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
- ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
+ ctxt.generateJavaSource(
+ " int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
ctxt.generateJavaSource(" if(status < 200 || status > 299){");
ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
- ctxt.generateJavaSource(" java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");");
+ ctxt.generateJavaSource(
+ " java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");");
ctxt.generateJavaSource(" StringBuilder " + sbName + " = new StringBuilder();");
String index = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource(" int " + index + ";");
- ctxt.generateJavaSource(" while(("+index+" = "+brName+".read()) != -1) "+sbName+".append((char)"+index+");");
- ctxt.generateJavaSource(" " + tempStringName + " = " +sbName + ".toString();");
+ ctxt.generateJavaSource(" while((" + index + " = " + brName + ".read()) != -1) " + sbName +
+ ".append((char)" + index + ");");
+ ctxt.generateJavaSource(" " + tempStringName + " = " + sbName + ".toString();");
ctxt.generateJavaSource("}else{");
- //if the url is relative, http request is needed.
+ // if the url is relative, http request is needed.
ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof HttpServletResponse)){");
- ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
- //get the servlet context of the context defined in the context attribute
+ // get the servlet context of the context defined in the context attribute
ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName + "){");
- ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" " + servletContextName +
+ " = pageContext.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
ctxt.generateJavaSource(" }");
- }else{
+ } else {
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
}
//
ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
- if(hasContext){
- ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" + contextName + "+ \" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
- }else{
- ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
+ if (hasContext) {
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" +
+ contextName + "+ \" \\\" and URL: \\\" \" +" + urlName +
+ "+ \" \\\". Verify values and/or enable cross context access.\");");
+ } else {
+ ctxt.generateJavaSource(
+ " throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" +
+ urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
}
ctxt.generateJavaSource(" }");
- //get the request dispatcher
- ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
- ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
+ // get the request dispatcher
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName +
+ ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName +
+ " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession(" +
+ urlName + "));");
- //initialize a ImportResponseWrapper to include the resource
- ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
+ // initialize a ImportResponseWrapper to include the resource
+ ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName +
+ " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
+ ctxt.generateJavaSource(
+ " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");");
ctxt.generateJavaSource(" try{");
- ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
+ ctxt.generateJavaSource(
+ " " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");");
ctxt.generateJavaSource(" }catch(java.io.IOException ex){");
ctxt.generateJavaSource(" throw new JspException(ex);");
ctxt.generateJavaSource(" }catch(RuntimeException ex){");
@@ -358,19 +396,21 @@ public class Import implements TagPlugin {
ctxt.generateJavaSource(" throw new JspException(rc);");
ctxt.generateJavaSource(" }");
- //validate the response status
+ // validate the response status
ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
- ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" throw new JspTagException(" + irwName +
+ ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" " + tempStringName + " = " + irwName + ".getString();");
ctxt.generateJavaSource("}");
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource("pageContext.setAttribute(\""+strVar+"\"," + tempStringName + "," + iScope + ");");
- }else{
+ ctxt.generateJavaSource(
+ "pageContext.setAttribute(\"" + strVar + "\"," + tempStringName + "," + iScope + ");");
+ } else {
ctxt.generateJavaSource("pageContext.getOut().print(" + tempStringName + ");");
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Out.java b/java/org/apache/jasper/tagplugins/jstl/core/Out.java
index a4590bcc0a..e48aa0cb5d 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Out.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Out.java
@@ -31,35 +31,33 @@ public final class Out implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //these two data member are to indicate
- //whether the corresponding attribute is specified
+ // these two data member are to indicate
+ // whether the corresponding attribute is specified
boolean hasDefault = ctxt.isAttributeSpecified("default");
boolean hasEscapeXml = ctxt.isAttributeSpecified("escapeXml");
- //strValName, strEscapeXmlName & strDefName are two variables' name
- //standing for value, escapeXml and default attribute
+ // strValName, strEscapeXmlName & strDefName are two variables' name
+ // standing for value, escapeXml and default attribute
String strObjectName = ctxt.getTemporaryVariableName();
String strValName = ctxt.getTemporaryVariableName();
String strDefName = ctxt.getTemporaryVariableName();
String strEscapeXmlName = ctxt.getTemporaryVariableName();
String strSkipBodyName = ctxt.getTemporaryVariableName();
- //according to the tag file, the value attribute is mandatory.
+ // according to the tag file, the value attribute is mandatory.
ctxt.generateImport("java.io.Reader");
ctxt.generateJavaSource("Object " + strObjectName + "=");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
ctxt.generateJavaSource("String " + strValName + "=null;");
- ctxt.generateJavaSource("if(!(" + strObjectName +
- " instanceof Reader) && "+ strObjectName + " != null){");
- ctxt.generateJavaSource(
- strValName + " = " + strObjectName + ".toString();");
+ ctxt.generateJavaSource("if(!(" + strObjectName + " instanceof Reader) && " + strObjectName + " != null){");
+ ctxt.generateJavaSource(strValName + " = " + strObjectName + ".toString();");
ctxt.generateJavaSource("}");
- //initiate the strDefName with null.
- //if the default has been specified, then assign the value to it;
+ // initiate the strDefName with null.
+ // if the default has been specified, then assign the value to it;
ctxt.generateJavaSource("String " + strDefName + " = null;");
- if(hasDefault){
+ if (hasDefault) {
ctxt.generateJavaSource("if(");
ctxt.generateAttribute("default");
ctxt.generateJavaSource(" != null){");
@@ -69,28 +67,26 @@ public final class Out implements TagPlugin {
ctxt.generateJavaSource("}");
}
- //initiate the strEscapeXmlName with true;
- //if the escapeXml is specified, assign the value to it;
+ // initiate the strEscapeXmlName with true;
+ // if the escapeXml is specified, assign the value to it;
ctxt.generateJavaSource("boolean " + strEscapeXmlName + " = true;");
- if(hasEscapeXml){
+ if (hasEscapeXml) {
ctxt.generateJavaSource(strEscapeXmlName + " = ");
ctxt.generateAttribute("escapeXml");
ctxt.generateJavaSource(";");
}
- //main part.
+ // main part.
ctxt.generateJavaSource(
- "boolean " + strSkipBodyName + " = " +
- "org.apache.jasper.tagplugins.jstl.core.Out.output(out, " +
- strObjectName + ", " + strValName + ", " + strDefName + ", " +
- strEscapeXmlName + ");");
+ "boolean " + strSkipBodyName + " = " + "org.apache.jasper.tagplugins.jstl.core.Out.output(out, " +
+ strObjectName + ", " + strValName + ", " + strDefName + ", " + strEscapeXmlName + ");");
ctxt.generateJavaSource("if(!" + strSkipBodyName + ") {");
ctxt.generateBody();
ctxt.generateJavaSource("}");
}
- public static boolean output(JspWriter out, Object input, String value,
- String defaultValue, boolean escapeXml) throws IOException {
+ public static boolean output(JspWriter out, Object input, String value, String defaultValue, boolean escapeXml)
+ throws IOException {
if (input instanceof Reader) {
char[] buffer = new char[8096];
int read = 0;
@@ -113,7 +109,7 @@ public final class Out implements TagPlugin {
} else {
String v = value != null ? value : defaultValue;
if (v != null) {
- if(escapeXml){
+ if (escapeXml) {
v = Util.escapeXml(v);
}
out.write(v);
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Param.java b/java/org/apache/jasper/tagplugins/jstl/core/Param.java
index 1496c5dbbc..d182cf118c 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Param.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Param.java
@@ -24,51 +24,55 @@ public class Param implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //don't support the body content
+ // don't support the body content
- //define names of all the temp variables
+ // define names of all the temp variables
String nameName = ctxt.getTemporaryVariableName();
String valueName = ctxt.getTemporaryVariableName();
String urlName = ctxt.getTemporaryVariableName();
String encName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
- //if the param tag has no parents, throw a exception
+ // if the param tag has no parents, throw a exception
TagPluginContext parent = ctxt.getParentContext();
- if(parent == null){
- ctxt.generateJavaSource(" throw new JspTagException" +
- "(\"<param> outside <import> or <urlEncode>\");");
+ if (parent == null) {
+ ctxt.generateJavaSource(
+ " throw new JspTagException" + "(\"<param> outside <import> or <urlEncode>\");");
return;
}
- //get the url string before adding this param
- ctxt.generateJavaSource("String " + urlName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
+ // get the url string before adding this param
+ ctxt.generateJavaSource(
+ "String " + urlName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");");
- //get the value of "name"
+ // get the value of "name"
ctxt.generateJavaSource("String " + nameName + " = ");
ctxt.generateAttribute("name");
ctxt.generateJavaSource(";");
- //if the "name" is null then do nothing.
- //else add such string "name=value" to the url.
- //and the url should be encoded
+ // if the "name" is null then do nothing.
+ // else add such string "name=value" to the url.
+ // and the url should be encoded
ctxt.generateJavaSource("if(" + nameName + " != null && !" + nameName + ".equals(\"\")){");
ctxt.generateJavaSource(" String " + valueName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
ctxt.generateJavaSource(" if(" + valueName + " == null) " + valueName + " = \"\";");
ctxt.generateJavaSource(" String " + encName + " = pageContext.getResponse().getCharacterEncoding();");
- ctxt.generateJavaSource(" " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");");
- ctxt.generateJavaSource(" " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");");
+ ctxt.generateJavaSource(
+ " " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");");
+ ctxt.generateJavaSource(
+ " " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");");
ctxt.generateJavaSource(" int " + index + ";");
ctxt.generateJavaSource(" " + index + " = " + urlName + ".indexOf(\'?\');");
- //if the current param is the first one, add a "?" ahead of it
- //else add a "&" ahead of it
+ // if the current param is the first one, add a "?" ahead of it
+ // else add a "&" ahead of it
ctxt.generateJavaSource(" if(" + index + " == -1){");
- ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";");
+ ctxt.generateJavaSource(
+ " " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
+ ctxt.generateJavaSource(
+ " " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
ctxt.generateJavaSource("}");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
index cd695ad478..a8c6d455ad 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
@@ -24,54 +24,51 @@ public class Redirect implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //flag for the existence of the "context"
+ // flag for the existence of the "context"
boolean hasContext = ctxt.isAttributeSpecified("context");
- //names of the temp variables
+ // names of the temp variables
String urlName = ctxt.getTemporaryVariableName();
String contextName = ctxt.getTemporaryVariableName();
String baseUrlName = ctxt.getTemporaryVariableName();
String resultName = ctxt.getTemporaryVariableName();
String responseName = ctxt.getTemporaryVariableName();
- //get context
+ // get context
ctxt.generateJavaSource("String " + contextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
}
- //get the url
+ // get the url
ctxt.generateJavaSource("String " + urlName + " = ");
ctxt.generateAttribute("url");
ctxt.generateJavaSource(";");
- //get the raw url according to "url" and "context"
- ctxt.generateJavaSource("String " + baseUrlName + " = " +
- "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + urlName + ", " + contextName + ", pageContext);");
- ctxt.generateJavaSource("pageContext.setAttribute" +
- "(\"url_without_param\", " + baseUrlName + ");");
+ // get the raw url according to "url" and "context"
+ ctxt.generateJavaSource("String " + baseUrlName + " = " + "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" +
+ urlName + ", " + contextName + ", pageContext);");
+ ctxt.generateJavaSource("pageContext.setAttribute" + "(\"url_without_param\", " + baseUrlName + ");");
- //add params
+ // add params
ctxt.generateBody();
- ctxt.generateJavaSource("String " + resultName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
- ctxt.generateJavaSource("pageContext.removeAttribute" +
- "(\"url_without_param\");");
+ ctxt.generateJavaSource(
+ "String " + resultName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource("pageContext.removeAttribute" + "(\"url_without_param\");");
- //get the response object
- ctxt.generateJavaSource("HttpServletResponse " + responseName + " = " +
- "((HttpServletResponse) pageContext.getResponse());");
+ // get the response object
+ ctxt.generateJavaSource(
+ "HttpServletResponse " + responseName + " = " + "((HttpServletResponse) pageContext.getResponse());");
- //if the url is relative, encode it
+ // if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
- ctxt.generateJavaSource(" " + resultName + " = "
- + responseName + ".encodeRedirectURL(" + resultName + ");");
+ ctxt.generateJavaSource(" " + resultName + " = " + responseName + ".encodeRedirectURL(" + resultName + ");");
ctxt.generateJavaSource("}");
- //do redirect
+ // do redirect
ctxt.generateJavaSource("try{");
ctxt.generateJavaSource(" " + responseName + ".sendRedirect(" + resultName + ");");
ctxt.generateJavaSource("}catch(java.io.IOException ex){");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
index 1978fe091f..3880594618 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
@@ -25,18 +25,18 @@ public class Remove implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //scope flag
+ // scope flag
boolean hasScope = ctxt.isAttributeSpecified("scope");
- //the value of the "var"
+ // the value of the "var"
String strVar = ctxt.getConstantAttribute("var");
- //remove attribute from certain scope.
- //default scope is "page".
- if(hasScope){
+ // remove attribute from certain scope.
+ // default scope is "page".
+ if (hasScope) {
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
- }else{
+ } else {
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
}
}
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Set.java b/java/org/apache/jasper/tagplugins/jstl/core/Set.java
index 8a64a1df74..ba3ddff6d0 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Set.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Set.java
@@ -25,42 +25,42 @@ public class Set implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //the scope name
+ // the scope name
String strScope;
- //the id of the scope
+ // the id of the scope
int iScope;
- //the flags to indicate whether the attributes have been specified
- //initialize the flags
+ // the flags to indicate whether the attributes have been specified
+ // initialize the flags
boolean hasValue = ctxt.isAttributeSpecified("value");
boolean hasVar = ctxt.isAttributeSpecified("var");
boolean hasScope = ctxt.isAttributeSpecified("scope");
boolean hasTarget = ctxt.isAttributeSpecified("target");
- //the temp variables name
+ // the temp variables name
String resultName = ctxt.getTemporaryVariableName();
String targetName = ctxt.getTemporaryVariableName();
String propertyName = ctxt.getTemporaryVariableName();
- //initialize the "result" which will be assigned to the var or target.property
+ // initialize the "result" which will be assigned to the var or target.property
ctxt.generateJavaSource("Object " + resultName + " = null;");
- if(hasValue){
+ if (hasValue) {
ctxt.generateJavaSource(resultName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
- }else{
+ } else {
ctxt.dontUseTagPlugin();
return;
}
- //initialize the strScope
- if(hasScope){
+ // initialize the strScope
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
- }else{
+ } else {
strScope = "page";
}
- //get the iScope according to the strScope
+ // get the iScope according to the strScope
iScope = Util.getScope(strScope);
String jspCtxt = null;
@@ -69,29 +69,30 @@ public class Set implements TagPlugin {
} else {
jspCtxt = "_jspx_page_context";
}
- //if the attribute var has been specified then assign the result to the var;
- if(hasVar){
+ // if the attribute var has been specified then assign the result to the var;
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource("if(null != " + resultName + "){");
- ctxt.generateJavaSource(" " + jspCtxt + ".setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");");
+ ctxt.generateJavaSource(
+ " " + jspCtxt + ".setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");");
ctxt.generateJavaSource("} else {");
- if(hasScope){
+ if (hasScope) {
ctxt.generateJavaSource(" " + jspCtxt + ".removeAttribute(\"" + strVar + "\"," + iScope + ");");
- }else{
+ } else {
ctxt.generateJavaSource(" " + jspCtxt + ".removeAttribute(\"" + strVar + "\");");
}
ctxt.generateJavaSource("}");
- //else assign the result to the target.property
- }else if(hasTarget){
+ // else assign the result to the target.property
+ } else if (hasTarget) {
- //generate the temp variable name
+ // generate the temp variable name
String pdName = ctxt.getTemporaryVariableName();
String successFlagName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
String methodName = ctxt.getTemporaryVariableName();
- //initialize the property
+ // initialize the property
ctxt.generateJavaSource("String " + propertyName + " = null;");
ctxt.generateJavaSource("if(");
ctxt.generateAttribute("property");
@@ -101,57 +102,69 @@ public class Set implements TagPlugin {
ctxt.generateJavaSource(").toString();");
ctxt.generateJavaSource("}");
- //initialize the target
+ // initialize the target
ctxt.generateJavaSource("Object " + targetName + " = ");
ctxt.generateAttribute("target");
ctxt.generateJavaSource(";");
- //the target is ok
+ // the target is ok
ctxt.generateJavaSource("if(" + targetName + " != null){");
- //if the target is a map, then put the result into the map with the key property
+ // if the target is a map, then put the result into the map with the key property
ctxt.generateJavaSource(" if(" + targetName + " instanceof java.util.Map){");
ctxt.generateJavaSource(" if(null != " + resultName + "){");
- ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").put(" + propertyName + "," + resultName + ");");
+ ctxt.generateJavaSource(
+ " ((java.util.Map) " + targetName + ").put(" + propertyName + "," + resultName + ");");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").remove(" + propertyName + ");");
ctxt.generateJavaSource(" }");
- //else assign the result to the target.property
+ // else assign the result to the target.property
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" try{");
- //get all the property of the target
- ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName + "[] = java.beans.Introspector.getBeanInfo(" + targetName + ".getClass()).getPropertyDescriptors();");
+ // get all the property of the target
+ ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName +
+ "[] = java.beans.Introspector.getBeanInfo(" + targetName +
+ ".getClass()).getPropertyDescriptors();");
- //the success flag is to imply whether the assign is successful
+ // the success flag is to imply whether the assign is successful
ctxt.generateJavaSource(" boolean " + successFlagName + " = false;");
- //find the right property
- ctxt.generateJavaSource(" for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){");
- ctxt.generateJavaSource(" if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){");
+ // find the right property
+ ctxt.generateJavaSource(
+ " for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){");
+ ctxt.generateJavaSource(
+ " if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){");
- //get the "set" method;
- ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName + "[" + index + "].getWriteMethod();");
+ // get the "set" method;
+ ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName +
+ "[" + index + "].getWriteMethod();");
ctxt.generateJavaSource(" if(null == " + methodName + "){");
- ctxt.generateJavaSource(" throw new JspException(\"No setter method in <set> for property \"+" + propertyName + ");");
+ ctxt.generateJavaSource(
+ " throw new JspException(\"No setter method in <set> for property \"+" +
+ propertyName + ");");
ctxt.generateJavaSource(" }");
- //invoke the method through the reflection
+ // invoke the method through the reflection
ctxt.generateJavaSource(" if(" + resultName + " != null){");
- ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{org.apache.el.lang.ELSupport.coerceToType(" + jspCtxt + ".getELContext(), " + resultName + ", " + methodName + ".getParameterTypes()[0])});");
+ ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName +
+ ", new Object[]{org.apache.el.lang.ELSupport.coerceToType(" + jspCtxt + ".getELContext(), " +
+ resultName + ", " + methodName + ".getParameterTypes()[0])});");
ctxt.generateJavaSource(" }else{");
- ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{null});");
+ ctxt.generateJavaSource(
+ " " + methodName + ".invoke(" + targetName + ", new Object[]{null});");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" " + successFlagName + " = true;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" if(!" + successFlagName + "){");
- ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" + propertyName + ");");
+ ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" +
+ propertyName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
- //catch the el exception and throw it as a JspException
+ // catch the el exception and throw it as a JspException
ctxt.generateJavaSource(" catch (IllegalAccessException ex) {");
ctxt.generateJavaSource(" throw new JspException(ex);");
ctxt.generateJavaSource(" } catch (java.beans.IntrospectionException ex) {");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Url.java b/java/org/apache/jasper/tagplugins/jstl/core/Url.java
index 6df77f6835..a771e969d4 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Url.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Url.java
@@ -25,70 +25,68 @@ public class Url implements TagPlugin {
@Override
public void doTag(TagPluginContext ctxt) {
- //flags
+ // flags
boolean hasVar, hasContext, hasScope;
- //init flags
+ // init flags
hasVar = ctxt.isAttributeSpecified("var");
hasContext = ctxt.isAttributeSpecified("context");
hasScope = ctxt.isAttributeSpecified("scope");
- //define name of the temp variables
+ // define name of the temp variables
String valueName = ctxt.getTemporaryVariableName();
String contextName = ctxt.getTemporaryVariableName();
String baseUrlName = ctxt.getTemporaryVariableName();
String resultName = ctxt.getTemporaryVariableName();
String responseName = ctxt.getTemporaryVariableName();
- //get the scope
+ // get the scope
String strScope = "page";
- if(hasScope){
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
}
int iScope = Util.getScope(strScope);
- //get the value
+ // get the value
ctxt.generateJavaSource("String " + valueName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
- //get the context
+ // get the context
ctxt.generateJavaSource("String " + contextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
}
- //get the raw url
- ctxt.generateJavaSource("String " + baseUrlName + " = " +
- "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + valueName + ", " + contextName + ", pageContext);");
- ctxt.generateJavaSource("pageContext.setAttribute" +
- "(\"url_without_param\", " + baseUrlName + ");");
+ // get the raw url
+ ctxt.generateJavaSource("String " + baseUrlName + " = " + "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" +
+ valueName + ", " + contextName + ", pageContext);");
+ ctxt.generateJavaSource("pageContext.setAttribute" + "(\"url_without_param\", " + baseUrlName + ");");
- //add params
+ // add params
ctxt.generateBody();
- ctxt.generateJavaSource("String " + resultName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
+ ctxt.generateJavaSource(
+ "String " + resultName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");");
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
- //if the url is relative, encode it
+ // if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
ctxt.generateJavaSource(" HttpServletResponse " + responseName + " = " +
- "((HttpServletResponse) pageContext.getResponse());");
- ctxt.generateJavaSource(" " + resultName + " = "
- + responseName + ".encodeURL(" + resultName + ");");
+ "((HttpServletResponse) pageContext.getResponse());");
+ ctxt.generateJavaSource(" " + resultName + " = " + responseName + ".encodeURL(" + resultName + ");");
ctxt.generateJavaSource("}");
- //if "var" is specified, the url string store in the attribute var defines
- if(hasVar){
+ // if "var" is specified, the url string store in the attribute var defines
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource("pageContext.setAttribute" +
- "(\"" + strVar + "\", " + resultName + ", " + iScope + ");");
+ ctxt.generateJavaSource(
+ "pageContext.setAttribute" + "(\"" + strVar + "\", " + resultName + ", " + iScope + ");");
- //if var is not specified, just print out the url string
- }else{
+ // if var is not specified, just print out the url string
+ } else {
ctxt.generateJavaSource("try{");
ctxt.generateJavaSource(" pageContext.getOut().print(" + resultName + ");");
ctxt.generateJavaSource("}catch(java.io.IOException ex){");
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/When.java b/java/org/apache/jasper/tagplugins/jstl/core/When.java
index 8a1141319c..b6568003e7 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/When.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/When.java
@@ -42,7 +42,7 @@ public final class When implements TagPlugin {
ctxt.generateBody();
// We don't generate the closing "}" for the "if" here because there
- // may be whitespaces in between <c:when>'s. Instead we delay
+ // may be whitespaces in between <c:when>'s. Instead we delay
// generating it until the next <c:when> or <c:otherwise> or
// <c:choose>
}
diff --git a/java/org/apache/jasper/util/FastRemovalDequeue.java b/java/org/apache/jasper/util/FastRemovalDequeue.java
index 64ec3dd26c..68bf0e89d9 100644
--- a/java/org/apache/jasper/util/FastRemovalDequeue.java
+++ b/java/org/apache/jasper/util/FastRemovalDequeue.java
@@ -17,31 +17,26 @@
package org.apache.jasper.util;
/**
- * The FastRemovalDequeue is a Dequeue that supports constant time removal of
- * entries. This is achieved by using a doubly linked list and wrapping any object
- * added to the collection with an Entry type, that is returned to the consumer.
- * When removing an object from the list, the consumer provides this Entry object.
+ * The FastRemovalDequeue is a Dequeue that supports constant time removal of entries. This is achieved by using a
+ * doubly linked list and wrapping any object added to the collection with an Entry type, that is returned to the
+ * consumer. When removing an object from the list, the consumer provides this Entry object.
* <p>
- * The Entry type is nearly opaque to the consumer of the queue. The only public
- * member is the getter for any object displaced when adding a new object to the
- * queue. This can be used to destroy that object.
+ * The Entry type is nearly opaque to the consumer of the queue. The only public member is the getter for any object
+ * displaced when adding a new object to the queue. This can be used to destroy that object.
* <p>
- * The Entry object contains the links pointing to the neighbours in the doubly
- * linked list, so that removal of an Entry does not need to search for it but
- * instead can be done in constant time.
+ * The Entry object contains the links pointing to the neighbours in the doubly linked list, so that removal of an Entry
+ * does not need to search for it but instead can be done in constant time.
* <p>
* The implementation is fully thread-safe.
* <p>
- * Invalidation of Entry objects during removal from the list is done
- * by setting their "valid" field to false. All public methods which take Entry
- * objects as arguments are NOP if the entry is no longer valid.
+ * Invalidation of Entry objects during removal from the list is done by setting their "valid" field to false. All
+ * public methods which take Entry objects as arguments are NOP if the entry is no longer valid.
* <p>
- * A typical use of the FastRemovalDequeue is a list of entries in sorted order,
- * where the sort position of an object will only switch to first or last.
+ * A typical use of the FastRemovalDequeue is a list of entries in sorted order, where the sort position of an object
+ * will only switch to first or last.
* <p>
- * Whenever the sort position needs to change, the consumer can remove the object
- * and reinsert it in front or at the end in constant time.
- * So keeping the list sorted is very cheap.
+ * Whenever the sort position needs to change, the consumer can remove the object and reinsert it in front or at the end
+ * in constant time. So keeping the list sorted is very cheap.
*
* @param <T> The type of elements in the queue
*/
@@ -59,11 +54,10 @@ public class FastRemovalDequeue<T> {
/**
* Initialize empty queue.
*
- * @param maxSize The maximum size to which the queue will be allowed to
- * grow
+ * @param maxSize The maximum size to which the queue will be allowed to grow
*/
public FastRemovalDequeue(int maxSize) {
- if (maxSize <=1 ) {
+ if (maxSize <= 1) {
maxSize = 2;
}
this.maxSize = maxSize;
@@ -73,23 +67,23 @@ public class FastRemovalDequeue<T> {
}
/**
- * Retrieve the size of the list.
- * This method also needs to be externally synchronized to
- * ensure correct publication of changes.
+ * Retrieve the size of the list. This method also needs to be externally synchronized to ensure correct publication
+ * of changes.
*
* @return the size of the list.
- * */
+ */
public synchronized int getSize() {
return size;
}
/**
- * Adds an object to the start of the list and returns the entry created for
- * said object. The entry can later be reused for moving the entry.
+ * Adds an object to the start of the list and returns the entry created for said object. The entry can later be
+ * reused for moving the entry.
*
* @param object the object to prepend to the start of the list.
+ *
* @return an entry for use when the object should be moved.
- * */
+ */
public synchronized Entry push(final T object) {
Entry entry = new Entry(object);
if (size >= maxSize) {
@@ -108,12 +102,13 @@ public class FastRemovalDequeue<T> {
}
/**
- * Adds an object to the end of the list and returns the entry created for
- * said object. The entry can later be reused for moving the entry.
+ * Adds an object to the end of the list and returns the entry created for said object. The entry can later be
+ * reused for moving the entry.
*
* @param object the object to append to the end of the list.
+ *
* @return an entry for use when the object should be moved.
- * */
+ */
public synchronized Entry unpop(final T object) {
Entry entry = new Entry(object);
if (size >= maxSize) {
@@ -143,7 +138,7 @@ public class FastRemovalDequeue<T> {
first = first.getNext();
content = element.getContent();
if (first == null) {
- last =null;
+ last = null;
} else {
first.setPrevious(null);
}
@@ -201,16 +196,13 @@ public class FastRemovalDequeue<T> {
}
/**
- * Moves the element in front.
- *
- * Could also be implemented as remove() and
- * push(), but explicitly coding might be a bit faster.
+ * Moves the element in front. Could also be implemented as remove() and push(), but explicitly coding might be a
+ * bit faster.
*
* @param element the entry to move in front.
- * */
+ */
public synchronized void moveFirst(final Entry element) {
- if (element.getValid() &&
- element.getPrevious() != null) {
+ if (element.getValid() && element.getPrevious() != null) {
Entry prev = element.getPrevious();
Entry next = element.getNext();
prev.setNext(next);
@@ -227,16 +219,13 @@ public class FastRemovalDequeue<T> {
}
/**
- * Moves the element to the back.
- *
- * Could also be implemented as remove() and
- * unpop(), but explicitly coding might be a bit faster.
+ * Moves the element to the back. Could also be implemented as remove() and unpop(), but explicitly coding might be
+ * a bit faster.
*
* @param element the entry to move to the back.
- * */
+ */
public synchronized void moveLast(final Entry element) {
- if (element.getValid() &&
- element.getNext() != null) {
+ if (element.getValid() && element.getNext() != null) {
Entry next = element.getNext();
Entry prev = element.getPrevious();
next.setPrevious(prev);
@@ -253,10 +242,8 @@ public class FastRemovalDequeue<T> {
}
/**
- * Implementation of a doubly linked list entry.
- * All implementation details are private.
- * For the consumer of the above collection, this
- * is simply garbage in, garbage out.
+ * Implementation of a doubly linked list entry. All implementation details are private. For the consumer of the
+ * above collection, this is simply garbage in, garbage out.
*/
public class Entry {
diff --git a/java/org/apache/jasper/util/UniqueAttributesImpl.java b/java/org/apache/jasper/util/UniqueAttributesImpl.java
index 8054b0eddd..49d1a2dc12 100644
--- a/java/org/apache/jasper/util/UniqueAttributesImpl.java
+++ b/java/org/apache/jasper/util/UniqueAttributesImpl.java
@@ -24,8 +24,8 @@ import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
/**
- * Wraps the default attributes implementation and ensures that each attribute
- * has a unique qname as required by the JSP specification.
+ * Wraps the default attributes implementation and ensures that each attribute has a unique qname as required by the JSP
+ * specification.
*/
public class UniqueAttributesImpl extends AttributesImpl {
@@ -60,8 +60,7 @@ public class UniqueAttributesImpl extends AttributesImpl {
}
@Override
- public void addAttribute(String uri, String localName, String qName,
- String type, String value) {
+ public void addAttribute(String uri, String localName, String qName, String type, String value) {
if (qNames.add(qName)) {
super.addAttribute(uri, localName, qName, type, value);
} else {
@@ -70,8 +69,7 @@ public class UniqueAttributesImpl extends AttributesImpl {
}
@Override
- public void setAttribute(int index, String uri, String localName,
- String qName, String type, String value) {
+ public void setAttribute(int index, String uri, String localName, String qName, String type, String value) {
qNames.remove(super.getQName(index));
if (qNames.add(qName)) {
super.setAttribute(index, uri, localName, qName, type, value);
@@ -114,7 +112,6 @@ public class UniqueAttributesImpl extends AttributesImpl {
}
// Ordinary tag attributes can't be repeated, even with identical values
- throw new IllegalArgumentException(
- Localizer.getMessage("jsp.error.duplicateqname", qName));
+ throw new IllegalArgumentException(Localizer.getMessage("jsp.error.duplicateqname", qName));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/04: Improve Javadoc formatting
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 7e210947d2c8d160305a5a6e4587f84cafdb3176
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 20 14:57:58 2025 +0000
Improve Javadoc formatting
---
java/org/apache/jasper/tagplugins/jstl/Util.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/jasper/tagplugins/jstl/Util.java b/java/org/apache/jasper/tagplugins/jstl/Util.java
index 8935c6ab32..aeecc01a04 100644
--- a/java/org/apache/jasper/tagplugins/jstl/Util.java
+++ b/java/org/apache/jasper/tagplugins/jstl/Util.java
@@ -187,13 +187,13 @@ public class Util {
/**
* Performs the following substring replacements
* (to facilitate output to XML/HTML pages):
- *
- * & -> &amp;
- * < -> &lt;
- * > -> &gt;
- * " -> &#034;
- * ' -> &#039;
- *
+ * <ul>
+ * <li>{@code &} -> {@code &}</li>
+ * <li>{@code <} -> {@code <}</li>
+ * <li>{@code >} -> {@code >}</li>
+ * <li>{@code "} -> {@code "}</li>
+ * <li>{@code '} -> {@code '}</li>
+ * </ul>
* See also OutSupport.writeEscapedXml().
*
* taken from org.apache.taglibs.standard.tag.common.core.Util
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 03/04: Improve Javadoc formatting
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 b7148ac33c49048cc1bbb822cf32d43cf290dd01
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 20 15:07:10 2025 +0000
Improve Javadoc formatting
---
java/org/apache/jasper/util/FastRemovalDequeue.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/jasper/util/FastRemovalDequeue.java b/java/org/apache/jasper/util/FastRemovalDequeue.java
index 2241ed638c..64ec3dd26c 100644
--- a/java/org/apache/jasper/util/FastRemovalDequeue.java
+++ b/java/org/apache/jasper/util/FastRemovalDequeue.java
@@ -21,24 +21,24 @@ package org.apache.jasper.util;
* entries. This is achieved by using a doubly linked list and wrapping any object
* added to the collection with an Entry type, that is returned to the consumer.
* When removing an object from the list, the consumer provides this Entry object.
- *
+ * <p>
* The Entry type is nearly opaque to the consumer of the queue. The only public
* member is the getter for any object displaced when adding a new object to the
* queue. This can be used to destroy that object.
- *
+ * <p>
* The Entry object contains the links pointing to the neighbours in the doubly
* linked list, so that removal of an Entry does not need to search for it but
* instead can be done in constant time.
- *
+ * <p>
* The implementation is fully thread-safe.
- *
+ * <p>
* Invalidation of Entry objects during removal from the list is done
* by setting their "valid" field to false. All public methods which take Entry
* objects as arguments are NOP if the entry is no longer valid.
- *
+ * <p>
* A typical use of the FastRemovalDequeue is a list of entries in sorted order,
* where the sort position of an object will only switch to first or last.
- *
+ * <p>
* Whenever the sort position needs to change, the consumer can remove the object
* and reinsert it in front or at the end in constant time.
* So keeping the list sorted is very cheap.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/04: Don't reformat inserted code blocks.
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 555616e34a0ced68fb9ef99d62f7c72225ecbc5f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 20 15:03:04 2025 +0000
Don't reformat inserted code blocks.
---
java/org/apache/jasper/tagplugins/jstl/core/ForEach.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
index 87c4b87854..19bdede07e 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
@@ -205,7 +205,7 @@ public final class ForEach implements TagPlugin {
* Generate iterators for data types supported in items
*/
private void generateIterators(TagPluginContext ctxt) {
-
+ //@formatter:off
// Object[]
ctxt.generateDeclaration("ObjectArrayIterator",
"private Iterator toIterator(final Object[] a){\n" +
@@ -344,6 +344,6 @@ public final class ForEach implements TagPlugin {
" });\n" +
"}"
);
-
+ //@formatter:on
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org