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
The following commit(s) were added to refs/heads/9.0.x by this push:
new 3146888d35 Code clean-up - formatting. No functional change.
3146888d35 is described below
commit 3146888d35cd3a1c718d5e147e4acd983bbe767c
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Mar 17 16:27:29 2025 +0000
Code clean-up - formatting. No functional change.
---
.../apache/jasper/servlet/JasperInitializer.java | 19 ++-
java/org/apache/jasper/servlet/JasperLoader.java | 62 ++++-----
.../apache/jasper/servlet/JspCServletContext.java | 73 ++++-------
java/org/apache/jasper/servlet/JspServlet.java | 138 +++++++++-----------
.../apache/jasper/servlet/JspServletWrapper.java | 142 +++++++++------------
java/org/apache/jasper/servlet/TldPreScanned.java | 8 +-
java/org/apache/jasper/servlet/TldScanner.java | 87 +++++--------
7 files changed, 212 insertions(+), 317 deletions(-)
diff --git a/java/org/apache/jasper/servlet/JasperInitializer.java
b/java/org/apache/jasper/servlet/JasperInitializer.java
index 8324bdcdb4..08999433bb 100644
--- a/java/org/apache/jasper/servlet/JasperInitializer.java
+++ b/java/org/apache/jasper/servlet/JasperInitializer.java
@@ -44,8 +44,8 @@ public class JasperInitializer implements
ServletContainerInitializer {
private final Log log = LogFactory.getLog(JasperInitializer.class); //
must not be static
/*
- * Preload classes required at runtime by a JSP servlet so that
- * we don't get a defineClassInPackage security exception.
+ * Preload classes required at runtime by a JSP servlet so that we don't
get a defineClassInPackage security
+ * exception.
*/
static {
JspFactoryImpl factory = new JspFactoryImpl();
@@ -62,14 +62,12 @@ public class JasperInitializer implements
ServletContainerInitializer {
}
// Setup a simple default Instance Manager
- if (context.getAttribute(InstanceManager.class.getName())==null) {
+ if (context.getAttribute(InstanceManager.class.getName()) == null) {
context.setAttribute(InstanceManager.class.getName(), new
SimpleInstanceManager());
}
- boolean validate = Boolean.parseBoolean(
-
context.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
- String blockExternalString = context.getInitParameter(
- Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
+ boolean validate =
Boolean.parseBoolean(context.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
+ String blockExternalString =
context.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
boolean blockExternal;
if (blockExternalString == null) {
blockExternal = true;
@@ -91,12 +89,11 @@ public class JasperInitializer implements
ServletContainerInitializer {
}
context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME,
- new TldCache(context, scanner.getUriTldResourcePathMap(),
- scanner.getTldResourcePathTaglibXmlMap()));
+ new TldCache(context, scanner.getUriTldResourcePathMap(),
scanner.getTldResourcePathTaglibXmlMap()));
}
- protected TldScanner newTldScanner(ServletContext context, boolean
namespaceAware,
- boolean validate, boolean blockExternal) {
+ protected TldScanner newTldScanner(ServletContext context, boolean
namespaceAware, boolean validate,
+ boolean blockExternal) {
return new TldScanner(context, namespaceAware, validate,
blockExternal);
}
}
diff --git a/java/org/apache/jasper/servlet/JasperLoader.java
b/java/org/apache/jasper/servlet/JasperLoader.java
index 670ab8ae5d..ec7e84d621 100644
--- a/java/org/apache/jasper/servlet/JasperLoader.java
+++ b/java/org/apache/jasper/servlet/JasperLoader.java
@@ -26,8 +26,8 @@ import java.security.PermissionCollection;
import org.apache.jasper.Constants;
/**
- * Class loader for loading servlet class files (corresponding to JSP files)
- * and tag handler class files (corresponding to tag files).
+ * Class loader for loading servlet class files (corresponding to JSP files)
and tag handler class files (corresponding
+ * to tag files).
*
* @author Anil K. Vijendran
* @author Harish Prabandham
@@ -37,17 +37,15 @@ public class JasperLoader extends URLClassLoader {
private final PermissionCollection permissionCollection;
private final SecurityManager securityManager;
- public JasperLoader(URL[] urls, ClassLoader parent,
- PermissionCollection permissionCollection) {
+ public JasperLoader(URL[] urls, ClassLoader parent, PermissionCollection
permissionCollection) {
super(urls, parent);
this.permissionCollection = permissionCollection;
this.securityManager = System.getSecurityManager();
}
/**
- * Load the class with the specified name. This method searches for
- * classes in the same manner as <code>loadClass(String, boolean)</code>
- * with <code>false</code> as the second argument.
+ * Load the class with the specified name. This method searches for
classes in the same manner as
+ * <code>loadClass(String, boolean)</code> with <code>false</code> as the
second argument.
*
* @param name Name of the class to be loaded
*
@@ -59,33 +57,26 @@ public class JasperLoader extends URLClassLoader {
}
/**
- * Load the class with the specified name, searching using the following
- * algorithm until it finds and returns the class. If the class cannot
- * be found, returns <code>ClassNotFoundException</code>.
+ * Load the class with the specified name, searching using the following
algorithm until it finds and returns the
+ * class. If the class cannot be found, returns
<code>ClassNotFoundException</code>.
* <ul>
- * <li>Call <code>findLoadedClass(String)</code> to check if the
- * class has already been loaded. If it has, the same
- * <code>Class</code> object is returned.</li>
- * <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>loadClass()</code> method of the parent class
- * loader, if any.</li>
- * <li>Call <code>findClass()</code> to find this class in our locally
- * defined repositories.</li>
- * <li>Call the <code>loadClass()</code> method of our parent
- * class loader, if any.</li>
+ * <li>Call <code>findLoadedClass(String)</code> to check if the class has
already been loaded. If it has, the same
+ * <code>Class</code> object is returned.</li>
+ * <li>If the <code>delegate</code> property is set to <code>true</code>,
call the <code>loadClass()</code> method
+ * of the parent class loader, if any.</li>
+ * <li>Call <code>findClass()</code> to find this class in our locally
defined repositories.</li>
+ * <li>Call the <code>loadClass()</code> method of our parent class
loader, if any.</li>
* </ul>
- * If the class was found using the above steps, and the
- * <code>resolve</code> flag is <code>true</code>, this method will then
- * call <code>resolveClass(Class)</code> on the resulting Class object.
+ * If the class was found using the above steps, and the
<code>resolve</code> flag is <code>true</code>, this method
+ * will then call <code>resolveClass(Class)</code> on the resulting Class
object.
*
- * @param name Name of the class to be loaded
+ * @param name Name of the class to be loaded
* @param resolve If <code>true</code> then resolve the class
*
* @exception ClassNotFoundException if the class was not found
*/
@Override
- public synchronized Class<?> loadClass(final String name, boolean resolve)
- throws ClassNotFoundException {
+ public synchronized Class<?> loadClass(final String name, boolean resolve)
throws ClassNotFoundException {
Class<?> clazz = null;
@@ -104,23 +95,22 @@ public class JasperLoader extends URLClassLoader {
if (dot >= 0) {
try {
// Do not call the security manager since by default, we
grant that package.
- if
(!"org.apache.jasper.runtime".equalsIgnoreCase(name.substring(0,dot))){
-
securityManager.checkPackageAccess(name.substring(0,dot));
+ if
(!"org.apache.jasper.runtime".equalsIgnoreCase(name.substring(0, dot))) {
+ securityManager.checkPackageAccess(name.substring(0,
dot));
}
} catch (SecurityException se) {
- String error = "Security Violation, attempt to use " +
- "Restricted Class: " + name;
+ String error = "Security Violation, attempt to use " +
"Restricted Class: " + name;
se.printStackTrace();
throw new ClassNotFoundException(error);
}
}
}
- if( !name.startsWith(Constants.JSP_PACKAGE_NAME + '.') ) {
+ if (!name.startsWith(Constants.JSP_PACKAGE_NAME + '.')) {
// Class is not in org.apache.jsp, therefore, have our
// parent load it
clazz = getParent().loadClass(name);
- if( resolve ) {
+ if (resolve) {
resolveClass(clazz);
}
return clazz;
@@ -153,13 +143,11 @@ public class JasperLoader extends URLClassLoader {
/**
- * Get the Permissions for a CodeSource.
- *
- * Since this ClassLoader is only used for a JSP page in
- * a web application context, we just return our preset
- * PermissionCollection for the web app context.
+ * Get the Permissions for a CodeSource. Since this ClassLoader is only
used for a JSP page in a web application
+ * context, we just return our preset PermissionCollection for the web app
context.
*
* @param codeSource Code source where the code was loaded from
+ *
* @return PermissionCollection for CodeSource
*/
@Override
diff --git a/java/org/apache/jasper/servlet/JspCServletContext.java
b/java/org/apache/jasper/servlet/JspCServletContext.java
index e09446fecf..c1a7b1d0c9 100644
--- a/java/org/apache/jasper/servlet/JspCServletContext.java
+++ b/java/org/apache/jasper/servlet/JspCServletContext.java
@@ -66,8 +66,7 @@ import org.apache.tomcat.util.scan.StandardJarScanner;
/**
- * Simple <code>ServletContext</code> implementation without
- * HTTP-specific methods.
+ * Simple <code>ServletContext</code> implementation without HTTP-specific
methods.
*
* @author Peter Rossbach ([email protected])
*/
@@ -125,21 +124,19 @@ public class JspCServletContext implements ServletContext
{
/**
* Create a new instance of this ServletContext implementation.
*
- * @param aLogWriter PrintWriter which is used for <code>log()</code> calls
+ * @param aLogWriter PrintWriter which is used for
<code>log()</code> calls
* @param aResourceBaseURL Resource base URL
- * @param classLoader Class loader for this {@link ServletContext}
- * @param validate Should a validating parser be used to parse
web.xml?
- * @param blockExternal Should external entities be blocked when parsing
- * web.xml?
+ * @param classLoader Class loader for this {@link ServletContext}
+ * @param validate Should a validating parser be used to parse
web.xml?
+ * @param blockExternal Should external entities be blocked when
parsing web.xml?
+ *
* @throws JasperException An error occurred building the merged web.xml
*/
- public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL,
- ClassLoader classLoader, boolean validate, boolean blockExternal)
- throws JasperException {
+ public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL,
ClassLoader classLoader, boolean validate,
+ boolean blockExternal) throws JasperException {
myAttributes = new HashMap<>();
- myParameters.put(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM,
- String.valueOf(blockExternal));
+ myParameters.put(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM,
String.valueOf(blockExternal));
myLogWriter = aLogWriter;
myResourceBaseURL = aResourceBaseURL;
this.loader = classLoader;
@@ -147,16 +144,14 @@ public class JspCServletContext implements ServletContext
{
jspConfigDescriptor = webXml.getJspConfigDescriptor();
}
- private WebXml buildMergedWebXml(boolean validate, boolean blockExternal)
- throws JasperException {
+ private WebXml buildMergedWebXml(boolean validate, boolean blockExternal)
throws JasperException {
WebXml webXml = new WebXml();
WebXmlParser webXmlParser = new WebXmlParser(validate, validate,
blockExternal);
// Use this class's classloader as Ant will have set the TCCL to its
own
webXmlParser.setClassLoader(getClass().getClassLoader());
try {
- URL url = getResource(
-
org.apache.tomcat.util.descriptor.web.Constants.WEB_XML_LOCATION);
+ URL url =
getResource(org.apache.tomcat.util.descriptor.web.Constants.WEB_XML_LOCATION);
if (!webXmlParser.parseWebXml(url, webXml, false)) {
throw new
JasperException(Localizer.getMessage("jspc.error.invalidWebXml"));
}
@@ -176,7 +171,7 @@ public class JspCServletContext implements ServletContext {
return webXml;
}
- Map<String, WebXml> fragments = scanForFragments(webXmlParser);
+ Map<String,WebXml> fragments = scanForFragments(webXmlParser);
Set<WebXml> orderedFragments = WebXml.orderWebFragments(webXml,
fragments, this);
// Find resource JARs
@@ -214,15 +209,14 @@ public class JspCServletContext implements ServletContext
{
}
- private Map<String, WebXml> scanForFragments(WebXmlParser webXmlParser)
throws JasperException {
+ private Map<String,WebXml> scanForFragments(WebXmlParser webXmlParser)
throws JasperException {
StandardJarScanner scanner = new StandardJarScanner();
// TODO - enabling this means initializing the classloader first in
JspC
scanner.setScanClassPath(false);
// TODO - configure filter rules from Ant rather then system properties
scanner.setJarScanFilter(new StandardJarScanFilter());
- FragmentJarScannerCallback callback =
- new FragmentJarScannerCallback(webXmlParser, false, true);
+ FragmentJarScannerCallback callback = new
FragmentJarScannerCallback(webXmlParser, false, true);
scanner.scan(JarScanType.PLUGGABILITY, this, callback);
if (!callback.isOk()) {
throw new
JasperException(Localizer.getMessage("jspc.error.invalidFragment"));
@@ -407,11 +401,9 @@ public class JspCServletContext implements ServletContext {
for (URL jarUrl : resourceJARs) {
try (Jar jar = JarFactory.newInstance(jarUrl)) {
jar.nextEntry();
- for (String entryName = jar.getEntryName();
- entryName != null;
- jar.nextEntry(), entryName = jar.getEntryName()) {
- if (entryName.startsWith(jarPath) &&
- entryName.length() > jarPath.length()) {
+ for (String entryName = jar.getEntryName(); entryName !=
null; jar.nextEntry(), entryName =
+ jar.getEntryName()) {
+ if (entryName.startsWith(jarPath) &&
entryName.length() > jarPath.length()) {
// Let the Set implementation handle duplicates
int sep = entryName.indexOf('/', jarPath.length());
if (sep < 0) {
@@ -506,15 +498,13 @@ public class JspCServletContext implements ServletContext
{
@Override
- public FilterRegistration.Dynamic addFilter(String filterName,
- String className) {
+ public FilterRegistration.Dynamic addFilter(String filterName, String
className) {
return null;
}
@Override
- public ServletRegistration.Dynamic addServlet(String servletName,
- String className) {
+ public ServletRegistration.Dynamic addServlet(String servletName, String
className) {
return null;
}
@@ -538,8 +528,7 @@ public class JspCServletContext implements ServletContext {
@Override
- public void setSessionTrackingModes(
- Set<SessionTrackingMode> sessionTrackingModes) {
+ public void setSessionTrackingModes(Set<SessionTrackingMode>
sessionTrackingModes) {
// Do nothing
}
@@ -551,22 +540,19 @@ public class JspCServletContext implements ServletContext
{
@Override
- public Dynamic addFilter(String filterName,
- Class<? extends Filter> filterClass) {
+ public Dynamic addFilter(String filterName, Class<? extends Filter>
filterClass) {
return null;
}
@Override
- public ServletRegistration.Dynamic addServlet(String servletName,
- Servlet servlet) {
+ public ServletRegistration.Dynamic addServlet(String servletName, Servlet
servlet) {
return null;
}
@Override
- public ServletRegistration.Dynamic addServlet(String servletName,
- Class<? extends Servlet> servletClass) {
+ public ServletRegistration.Dynamic addServlet(String servletName, Class<?
extends Servlet> servletClass) {
return null;
}
@@ -578,15 +564,13 @@ public class JspCServletContext implements ServletContext
{
@Override
- public <T extends Filter> T createFilter(Class<T> c)
- throws ServletException {
+ public <T extends Filter> T createFilter(Class<T> c) throws
ServletException {
return null;
}
@Override
- public <T extends Servlet> T createServlet(Class<T> c)
- throws ServletException {
+ public <T extends Servlet> T createServlet(Class<T> c) throws
ServletException {
return null;
}
@@ -628,8 +612,7 @@ public class JspCServletContext implements ServletContext {
@Override
- public <T extends EventListener> T createListener(Class<T> c)
- throws ServletException {
+ public <T extends EventListener> T createListener(Class<T> c) throws
ServletException {
return null;
}
@@ -659,7 +642,7 @@ public class JspCServletContext implements ServletContext {
@Override
- public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
+ public Map<String,? extends FilterRegistration> getFilterRegistrations() {
return null;
}
@@ -671,7 +654,7 @@ public class JspCServletContext implements ServletContext {
@Override
- public Map<String, ? extends ServletRegistration>
getServletRegistrations() {
+ public Map<String,? extends ServletRegistration> getServletRegistrations()
{
return null;
}
diff --git a/java/org/apache/jasper/servlet/JspServlet.java
b/java/org/apache/jasper/servlet/JspServlet.java
index a73493422a..8f2b15f73b 100644
--- a/java/org/apache/jasper/servlet/JspServlet.java
+++ b/java/org/apache/jasper/servlet/JspServlet.java
@@ -45,14 +45,10 @@ import org.apache.tomcat.PeriodicEventListener;
import org.apache.tomcat.util.security.Escape;
/**
- * The JSP engine (a.k.a Jasper).
- *
- * The servlet container is responsible for providing a
- * URLClassLoader for the web application context Jasper
- * is being used in. Jasper will try get the Tomcat
- * ServletContext attribute for its ServletContext class
- * loader, if that fails, it uses the parent class loader.
- * In either case, it must be a URLClassLoader.
+ * The JSP engine (a.k.a Jasper). The servlet container is responsible for
providing a URLClassLoader for the web
+ * application context Jasper is being used in. Jasper will try get the Tomcat
ServletContext attribute for its
+ * ServletContext class loader, if that fails, it uses the parent class
loader. In either case, it must be a
+ * URLClassLoader.
*
* @author Anil K. Vijendran
* @author Harish Prabandham
@@ -87,8 +83,7 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
// Check for a custom Options implementation
String engineOptionsName =
config.getInitParameter("engineOptionsClass");
if (Constants.IS_SECURITY_ENABLED && engineOptionsName != null) {
- log.info(Localizer.getMessage(
- "jsp.info.ignoreSetting", "engineOptionsClass",
engineOptionsName));
+ log.info(Localizer.getMessage("jsp.info.ignoreSetting",
"engineOptionsClass", engineOptionsName));
engineOptionsName = null;
}
if (engineOptionsName != null) {
@@ -123,11 +118,11 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
throw new
ServletException(Localizer.getMessage("jsp.error.no.jsp", jspFile), e);
}
try {
- if (SecurityUtil.isPackageProtectionEnabled()){
-
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
- serviceJspFile(null, null, jspFile, true);
- return null;
- });
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
+ serviceJspFile(null, null, jspFile, true);
+ return null;
+ });
} else {
serviceJspFile(null, null, jspFile, true);
}
@@ -136,29 +131,26 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
} catch (PrivilegedActionException e) {
Throwable t = e.getCause();
if (t instanceof ServletException) {
- throw (ServletException)t;
+ throw (ServletException) t;
}
throw new
ServletException(Localizer.getMessage("jsp.error.precompilation", jspFile), e);
}
}
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.message.scratch.dir.is",
- options.getScratchDir().toString()));
+ log.debug(Localizer.getMessage("jsp.message.scratch.dir.is",
options.getScratchDir().toString()));
log.debug(Localizer.getMessage("jsp.message.dont.modify.servlets"));
}
}
/**
- * Returns the number of JSPs for which JspServletWrappers exist, i.e.,
- * the number of JSPs that have been loaded into the webapp with which
- * this JspServlet is associated.
- *
- * <p>This info may be used for monitoring purposes.
+ * Returns the number of JSPs for which JspServletWrappers exist, i.e.,
the number of JSPs that have been loaded
+ * into the webapp with which this JspServlet is associated.
+ * <p>
+ * This info may be used for monitoring purposes.
*
- * @return The number of JSPs that have been loaded into the webapp with
- * which this JspServlet is associated
+ * @return The number of JSPs that have been loaded into the webapp with
which this JspServlet is associated
*/
public int getJspCount() {
return this.rctxt.getJspCount();
@@ -177,11 +169,10 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
/**
* Gets the number of JSPs that have been reloaded.
+ * <p>
+ * This info may be used for monitoring purposes.
*
- * <p>This info may be used for monitoring purposes.
- *
- * @return The number of JSPs (in the webapp with which this JspServlet is
- * associated) that have been reloaded
+ * @return The number of JSPs (in the webapp with which this JspServlet is
associated) that have been reloaded
*/
public int getJspReloadCount() {
return this.rctxt.getJspReloadCount();
@@ -190,11 +181,11 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
/**
* Gets the number of JSPs that are in the JSP limiter queue
+ * <p>
+ * This info may be used for monitoring purposes.
*
- * <p>This info may be used for monitoring purposes.
- *
- * @return The number of JSPs (in the webapp with which this JspServlet is
- * associated) that are in the JSP limiter queue
+ * @return The number of JSPs (in the webapp with which this JspServlet is
associated) that are in the JSP limiter
+ * queue
*/
public int getJspQueueLength() {
return this.rctxt.getJspQueueLength();
@@ -203,11 +194,10 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
/**
* Gets the number of JSPs that have been unloaded.
+ * <p>
+ * This info may be used for monitoring purposes.
*
- * <p>This info may be used for monitoring purposes.
- *
- * @return The number of JSPs (in the webapp with which this JspServlet is
- * associated) that have been unloaded
+ * @return The number of JSPs (in the webapp with which this JspServlet is
associated) that have been unloaded
*/
public int getJspUnloadCount() {
return this.rctxt.getJspUnloadCount();
@@ -215,17 +205,17 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
/**
- * <p>Look for a <em>precompilation request</em> as described in
- * Section 8.4.2 of the JSP 1.2 Specification. <strong>WARNING</strong> -
- * we cannot use <code>request.getParameter()</code> for this, because
- * that will trigger parsing all of the request parameters, and not give
- * a servlet the opportunity to call
- * <code>request.setCharacterEncoding()</code> first.</p>
+ * <p>
+ * Look for a <em>precompilation request</em> as described in Section
8.4.2 of the JSP 1.2 Specification.
+ * <strong>WARNING</strong> - we cannot use
<code>request.getParameter()</code> for this, because that will trigger
+ * parsing all of the request parameters, and not give a servlet the
opportunity to call
+ * <code>request.setCharacterEncoding()</code> first.
+ * </p>
*
* @param request The servlet request we are processing
*
- * @exception ServletException if an invalid parameter value for the
- * <code>jsp_precompile</code> parameter name is specified
+ * @exception ServletException if an invalid parameter value for the
<code>jsp_precompile</code> parameter name is
+ * specified
*/
boolean preCompile(HttpServletRequest request) throws ServletException {
@@ -237,16 +227,15 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
if (start < 0) {
return false;
}
- queryString =
- queryString.substring(start + Constants.PRECOMPILE.length());
+ queryString = queryString.substring(start +
Constants.PRECOMPILE.length());
if (queryString.length() == 0) {
- return true; // ?jsp_precompile
+ return true; // ?jsp_precompile
}
if (queryString.startsWith("&")) {
- return true; // ?jsp_precompile&foo=bar...
+ return true; // ?jsp_precompile&foo=bar...
}
if (!queryString.startsWith("=")) {
- return false; // part of some other name or value
+ return false; // part of some other name or value
}
int limit = queryString.length();
int ampersand = queryString.indexOf('&');
@@ -255,51 +244,45 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
}
String value = queryString.substring(1, limit);
if (value.equals("true")) {
- return true; // ?jsp_precompile=true
+ return true; // ?jsp_precompile=true
} else if (value.equals("false")) {
// Spec says if jsp_precompile=false, the request should not
// be delivered to the JSP page; the easiest way to implement
// this is to set the flag to true, and precompile the page anyway.
// This still conforms to the spec, since it says the
// precompilation request can be ignored.
- return true; // ?jsp_precompile=false
+ return true; // ?jsp_precompile=false
} else {
- throw new
ServletException(Localizer.getMessage("jsp.error.precompilation.parameter",
- Constants.PRECOMPILE, value));
+ throw new ServletException(
+ Localizer.getMessage("jsp.error.precompilation.parameter",
Constants.PRECOMPILE, value));
}
}
@Override
- public void service (HttpServletRequest request, HttpServletResponse
response)
- throws ServletException, IOException {
+ public void service(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// jspFile may be configured as an init-param for this servlet instance
String jspUri = jspFile;
if (jspUri == null) {
/*
- * Check to see if the requested JSP has been the target of a
- * RequestDispatcher.include()
+ * Check to see if the requested JSP has been the target of a
RequestDispatcher.include()
*/
- jspUri = (String) request.getAttribute(
- RequestDispatcher.INCLUDE_SERVLET_PATH);
+ jspUri = (String)
request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
if (jspUri != null) {
/*
- * Requested JSP has been target of
- * RequestDispatcher.include(). Its path is assembled from the
- * relevant javax.servlet.include.* request attributes
+ * Requested JSP has been target of
RequestDispatcher.include(). Its path is assembled from the relevant
+ * javax.servlet.include.* request attributes
*/
- String pathInfo = (String) request.getAttribute(
- RequestDispatcher.INCLUDE_PATH_INFO);
+ String pathInfo = (String)
request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
if (pathInfo != null) {
jspUri += pathInfo;
}
} else {
/*
- * Requested JSP has not been the target of a
- * RequestDispatcher.include(). Reconstruct its path from the
+ * Requested JSP has not been the target of a
RequestDispatcher.include(). Reconstruct its path from the
* request's getServletPath() and getPathInfo()
*/
jspUri = request.getServletPath();
@@ -349,14 +332,12 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
// -------------------------------------------------------- Private Methods
- private void serviceJspFile(HttpServletRequest request,
- HttpServletResponse response, String jspUri,
- boolean precompile)
- throws ServletException, IOException {
+ private void serviceJspFile(HttpServletRequest request,
HttpServletResponse response, String jspUri,
+ boolean precompile) throws ServletException, IOException {
JspServletWrapper wrapper = rctxt.getWrapper(jspUri);
if (wrapper == null) {
- synchronized(this) {
+ synchronized (this) {
wrapper = rctxt.getWrapper(jspUri);
if (wrapper == null) {
// Check if the requested JSP page exists, to avoid
@@ -365,9 +346,8 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
handleMissingResource(request, response, jspUri);
return;
}
- wrapper = new JspServletWrapper(config, options, jspUri,
- rctxt);
- rctxt.addWrapper(jspUri,wrapper);
+ wrapper = new JspServletWrapper(config, options, jspUri,
rctxt);
+ rctxt.addWrapper(jspUri, wrapper);
}
}
}
@@ -381,14 +361,12 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
}
- private void handleMissingResource(HttpServletRequest request,
- HttpServletResponse response, String jspUri)
+ private void handleMissingResource(HttpServletRequest request,
HttpServletResponse response, String jspUri)
throws ServletException, IOException {
- String includeRequestUri =
-
(String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
+ String includeRequestUri = (String)
request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
- String msg = Localizer.getMessage("jsp.error.file.not.found",jspUri);
+ String msg = Localizer.getMessage("jsp.error.file.not.found", jspUri);
if (includeRequestUri != null) {
// This file was included. Throw an exception as
// a response.sendError() will be ignored
diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java
b/java/org/apache/jasper/servlet/JspServletWrapper.java
index 30bf73d8a8..db5319f2da 100644
--- a/java/org/apache/jasper/servlet/JspServletWrapper.java
+++ b/java/org/apache/jasper/servlet/JspServletWrapper.java
@@ -50,14 +50,10 @@ import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.Jar;
/**
- * The JSP engine (a.k.a Jasper).
- *
- * The servlet container is responsible for providing a
- * URLClassLoader for the web application context Jasper
- * is being used in. Jasper will try get the Tomcat
- * ServletContext attribute for its ServletContext class
- * loader, if that fails, it uses the parent class loader.
- * In either case, it must be a URLClassLoader.
+ * The JSP engine (a.k.a Jasper). The servlet container is responsible for
providing a URLClassLoader for the web
+ * application context Jasper is being used in. Jasper will try get the Tomcat
ServletContext attribute for its
+ * ServletContext class loader, if that fails, it uses the parent class
loader. In either case, it must be a
+ * URLClassLoader.
*
* @author Anil K. Vijendran
* @author Harish Prabandham
@@ -70,8 +66,7 @@ import org.apache.tomcat.Jar;
@SuppressWarnings("deprecation") // Have to support SingleThreadModel
public class JspServletWrapper {
- private static final Map<String,Long> ALWAYS_OUTDATED_DEPENDENCIES =
- new HashMap<>();
+ private static final Map<String,Long> ALWAYS_OUTDATED_DEPENDENCIES = new
HashMap<>();
static {
// If this is missing,
@@ -89,11 +84,9 @@ public class JspServletWrapper {
private final ServletConfig config;
private final Options options;
/*
- * The servlet / tag file needs a compilation check on first access. Use a
- * separate flag (rather then theServlet == null / tagHandlerClass == null
- * as it avoids the potentially expensive isOutDated() calls in
- * ctxt.compile() if there are multiple concurrent requests for the servlet
- * / tag before the class has been loaded.
+ * The servlet / tag file needs a compilation check on first access. Use a
separate flag (rather then theServlet ==
+ * null / tagHandlerClass == null as it avoids the potentially expensive
isOutDated() calls in ctxt.compile() if
+ * there are multiple concurrent requests for the servlet / tag before the
class has been loaded.
*/
private volatile boolean mustCompile = true;
/* Whether the servlet/tag file needs reloading on next access */
@@ -113,8 +106,7 @@ public class JspServletWrapper {
/*
* JspServletWrapper for JSP pages.
*/
- public JspServletWrapper(ServletConfig config, Options options,
- String jspUri, JspRuntimeContext rctxt) {
+ public JspServletWrapper(ServletConfig config, Options options, String
jspUri, JspRuntimeContext rctxt) {
this.isTagFile = false;
this.config = config;
@@ -123,32 +115,24 @@ public class JspServletWrapper {
unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
unloadAllowed = unloadByCount || unloadByIdle ? true : false;
- ctxt = new JspCompilationContext(jspUri, options,
- config.getServletContext(),
- this, rctxt);
+ ctxt = new JspCompilationContext(jspUri, options,
config.getServletContext(), this, rctxt);
}
/*
* JspServletWrapper for tag files.
*/
- public JspServletWrapper(ServletContext servletContext,
- Options options,
- String tagFilePath,
- TagInfo tagInfo,
- JspRuntimeContext rctxt,
- Jar tagJar) {
+ public JspServletWrapper(ServletContext servletContext, Options options,
String tagFilePath, TagInfo tagInfo,
+ JspRuntimeContext rctxt, Jar tagJar) {
this.isTagFile = true;
- this.config = null; // not used
+ this.config = null; // not used
this.options = options;
this.jspUri = tagFilePath;
this.tripCount = 0;
unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
unloadAllowed = unloadByCount || unloadByIdle ? true : false;
- ctxt = new JspCompilationContext(jspUri, tagInfo, options,
- servletContext, this, rctxt,
- tagJar);
+ ctxt = new JspCompilationContext(jspUri, tagInfo, options,
servletContext, this, rctxt, tagJar);
}
public JspCompilationContext getJspEngineContext() {
@@ -169,13 +153,11 @@ public class JspServletWrapper {
public Servlet getServlet() throws ServletException {
/*
- * DCL on 'reload' requires that 'reload' be volatile
- * (this also forces a read memory barrier, ensuring the new servlet
- * object is read consistently).
+ * DCL on 'reload' requires that 'reload' be volatile (this also
forces a read memory barrier, ensuring the new
+ * servlet object is read consistently).
*
- * When running in non development mode with a checkInterval it is
- * possible (see BZ 62603) for a race condition to cause failures
- * if a Servlet or tag is reloaded while a compile check is running
+ * When running in non development mode with a checkInterval it is
possible (see BZ 62603) for a race condition
+ * to cause failures if a Servlet or tag is reloaded while a compile
check is running
*/
if (getReloadInternal() || theServlet == null) {
synchronized (this) {
@@ -191,8 +173,7 @@ public class JspServletWrapper {
InstanceManager instanceManager =
InstanceManagerFactory.getInstanceManager(config);
servlet = (Servlet)
instanceManager.newInstance(ctxt.getFQCN(), ctxt.getJspLoader());
} catch (Exception e) {
- Throwable t = ExceptionUtils
- .unwrapInvocationTargetException(e);
+ Throwable t =
ExceptionUtils.unwrapInvocationTargetException(e);
ExceptionUtils.handleThrowable(t);
throw new JasperException(t);
}
@@ -226,8 +207,7 @@ public class JspServletWrapper {
}
/**
- * Sets the last-modified time of the servlet class file associated with
- * this JspServletWrapper.
+ * Sets the last-modified time of the servlet class file associated with
this JspServletWrapper.
*
* @param lastModified Last-modified time of servlet class
*/
@@ -245,7 +225,7 @@ public class JspServletWrapper {
// a new loader will be created which will load the new
// class.
// TODO Are there inefficiencies between reload and the
- // isOutDated() check?
+ // isOutDated() check?
ctxt.clearJspLoader();
}
}
@@ -254,7 +234,9 @@ public class JspServletWrapper {
/**
* Compile (if needed) and load a tag file.
+ *
* @return the loaded class
+ *
* @throws JasperException Error compiling or loading tag file
*/
public Class<?> loadTagFile() throws JasperException {
@@ -293,11 +275,11 @@ public class JspServletWrapper {
}
/**
- * Compile and load a prototype for the Tag file. This is needed
- * when compiling tag files with circular dependencies. A prototype
- * (skeleton) with no dependencies on other other tag files is
- * generated and compiled.
+ * Compile and load a prototype for the Tag file. This is needed when
compiling tag files with circular
+ * dependencies. A prototype (skeleton) with no dependencies on other
other tag files is generated and compiled.
+ *
* @return the loaded class
+ *
* @throws JasperException Error compiling or loading tag file
*/
public Class<?> loadTagFilePrototype() throws JasperException {
@@ -312,6 +294,7 @@ public class JspServletWrapper {
/**
* Get a list of files that the current page has source dependency on.
+ *
* @return the map of dependent resources
*/
public Map<String,Long> getDependants() {
@@ -363,9 +346,7 @@ public class JspServletWrapper {
return unloadHandle;
}
- public void service(HttpServletRequest request,
- HttpServletResponse response,
- boolean precompile)
+ public void service(HttpServletRequest request, HttpServletResponse
response, boolean precompile)
throws ServletException, IOException, FileNotFoundException {
Servlet servlet;
@@ -379,9 +360,8 @@ public class JspServletWrapper {
if ((available > 0L) && (available < Long.MAX_VALUE)) {
if (available > System.currentTimeMillis()) {
response.setDateHeader("Retry-After", available);
- response.sendError
- (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
- Localizer.getMessage("jsp.error.unavailable"));
+
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
+ Localizer.getMessage("jsp.error.unavailable"));
return;
}
@@ -437,7 +417,7 @@ public class JspServletWrapper {
* (3) Handle limitation of number of loaded Jsps
*/
if (unloadAllowed) {
- synchronized(this) {
+ synchronized (this) {
if (unloadByCount) {
if (unloadHandle == null) {
unloadHandle = ctxt.getRuntimeContext().push(this);
@@ -457,17 +437,16 @@ public class JspServletWrapper {
* (4) Service request
*/
if (servlet instanceof SingleThreadModel) {
- // sync on the wrapper so that the freshness
- // of the page is determined right before servicing
- synchronized (this) {
- servlet.service(request, response);
+ // sync on the wrapper so that the freshness
+ // of the page is determined right before servicing
+ synchronized (this) {
+ servlet.service(request, response);
}
} else {
servlet.service(request, response);
}
} catch (UnavailableException ex) {
- String includeRequestUri = (String)
- request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
+ String includeRequestUri = (String)
request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
if (includeRequestUri != null) {
// This file was included. Throw an exception as
// a response.sendError() will be ignored by the
@@ -477,15 +456,12 @@ public class JspServletWrapper {
int unavailableSeconds = ex.getUnavailableSeconds();
if (unavailableSeconds <= 0) {
- unavailableSeconds = 60; // Arbitrary default
+ unavailableSeconds = 60; // Arbitrary default
}
- available = System.currentTimeMillis() +
- (unavailableSeconds * 1000L);
- response.sendError
- (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
- ex.getMessage());
+ available = System.currentTimeMillis() + (unavailableSeconds *
1000L);
+ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
ex.getMessage());
} catch (ServletException | IllegalStateException ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
}
throw ex;
@@ -495,7 +471,7 @@ public class JspServletWrapper {
}
throw ex;
} catch (Exception ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
}
throw new JasperException(ex);
@@ -517,8 +493,7 @@ public class JspServletWrapper {
Throwable t =
ExceptionUtils.unwrapInvocationTargetException(e);
ExceptionUtils.handleThrowable(t);
// Log any exception, since it can't be passed along
- log.error(Localizer.getMessage("jsp.error.file.not.found",
- e.getMessage()), t);
+ log.error(Localizer.getMessage("jsp.error.file.not.found",
e.getMessage()), t);
}
}
}
@@ -529,6 +504,7 @@ public class JspServletWrapper {
public long getLastModificationTest() {
return lastModificationTest;
}
+
/**
* @param lastModificationTest The lastModificationTest to set.
*/
@@ -544,16 +520,16 @@ public class JspServletWrapper {
}
/**
- * <p>Attempts to construct a JasperException that contains helpful
information
- * about what went wrong. Uses the JSP compiler system to translate the
line
- * number in the generated servlet that originated the exception to a line
- * number in the JSP. Then constructs an exception containing that
- * information, and a snippet of the JSP to help debugging.
- * Please see https://bz.apache.org/bugzilla/show_bug.cgi?id=37062 and
- * http://www.tfenne.com/jasper/ for more details.
+ * <p>
+ * Attempts to construct a JasperException that contains helpful
information about what went wrong. Uses the JSP
+ * compiler system to translate the line number in the generated servlet
that originated the exception to a line
+ * number in the JSP. Then constructs an exception containing that
information, and a snippet of the JSP to help
+ * debugging. Please see
https://bz.apache.org/bugzilla/show_bug.cgi?id=37062 and
http://www.tfenne.com/jasper/ for
+ * more details.
* </p>
*
* @param ex the exception that was the cause of the problem.
+ *
* @return a JasperException with more detailed information
*/
protected JasperException handleJspException(Exception ex) {
@@ -603,18 +579,16 @@ public class JspServletWrapper {
source.getFileName(), source.getLineNumber(), null, ctxt);
if (options.getDisplaySourceFragment()) {
- return new JasperException(Localizer.getMessage
- ("jsp.exception", detail.getJspFileName(),
- "" + source.getLineNumber()) +
System.lineSeparator() +
- System.lineSeparator() +
detail.getJspExtract() +
- System.lineSeparator() +
System.lineSeparator() +
- "Stacktrace:", ex);
+ return new JasperException(
+ Localizer.getMessage("jsp.exception",
detail.getJspFileName(), "" + source.getLineNumber()) +
+ System.lineSeparator() +
System.lineSeparator() + detail.getJspExtract() +
+ System.lineSeparator() +
System.lineSeparator() + "Stacktrace:",
+ ex);
}
- return new JasperException(Localizer.getMessage
- ("jsp.exception", detail.getJspFileName(),
- "" + source.getLineNumber()), ex);
+ return new JasperException(
+ Localizer.getMessage("jsp.exception",
detail.getJspFileName(), "" + source.getLineNumber()), ex);
} catch (Exception je) {
// If anything goes wrong, just revert to the original behaviour
if (ex instanceof JasperException) {
diff --git a/java/org/apache/jasper/servlet/TldPreScanned.java
b/java/org/apache/jasper/servlet/TldPreScanned.java
index a5401e4a88..b6b450adf2 100644
--- a/java/org/apache/jasper/servlet/TldPreScanned.java
+++ b/java/org/apache/jasper/servlet/TldPreScanned.java
@@ -29,19 +29,19 @@ public class TldPreScanned extends TldScanner {
private final Collection<URL> preScannedURLs;
- public TldPreScanned (ServletContext context, boolean namespaceAware,
boolean validation,
- boolean blockExternal, Collection<URL> preScannedTlds) {
+ public TldPreScanned(ServletContext context, boolean namespaceAware,
boolean validation, boolean blockExternal,
+ Collection<URL> preScannedTlds) {
super(context, namespaceAware, validation, blockExternal);
preScannedURLs = preScannedTlds;
}
@Override
public void scanJars() {
- for (URL url : preScannedURLs){
+ for (URL url : preScannedURLs) {
String str = url.toExternalForm();
int a = str.indexOf("jar:");
int b = str.indexOf("!/");
- if (a >= 0 && b> 0) {
+ if (a >= 0 && b > 0) {
String fileUrl = str.substring(a + 4, b);
String path = str.substring(b + 2);
try {
diff --git a/java/org/apache/jasper/servlet/TldScanner.java
b/java/org/apache/jasper/servlet/TldScanner.java
index 4561739dc3..2379955ad8 100644
--- a/java/org/apache/jasper/servlet/TldScanner.java
+++ b/java/org/apache/jasper/servlet/TldScanner.java
@@ -59,26 +59,20 @@ public class TldScanner {
private static final String WEB_INF = "/WEB-INF/";
private final ServletContext context;
private final TldParser tldParser;
- private final Map<String, TldResourcePath> uriTldResourcePathMap = new
HashMap<>();
- private final Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap
= new HashMap<>();
+ private final Map<String,TldResourcePath> uriTldResourcePathMap = new
HashMap<>();
+ private final Map<TldResourcePath,TaglibXml> tldResourcePathTaglibXmlMap =
new HashMap<>();
private final List<String> listeners = new ArrayList<>();
/**
* Initialise with the application's ServletContext.
*
* @param context the application's servletContext
- * @param namespaceAware should the XML parser used to parse TLD files be
- * configured to be name space aware
- * @param validation should the XML parser used to parse TLD files be
- * configured to use validation
- * @param blockExternal should the XML parser used to parse TLD files be
- * configured to be block references to external
- * entities
+ * @param namespaceAware should the XML parser used to parse TLD files be
configured to be name space aware
+ * @param validation should the XML parser used to parse TLD files be
configured to use validation
+ * @param blockExternal should the XML parser used to parse TLD files be
configured to be block references to
+ * external entities
*/
- public TldScanner(ServletContext context,
- boolean namespaceAware,
- boolean validation,
- boolean blockExternal) {
+ public TldScanner(ServletContext context, boolean namespaceAware, boolean
validation, boolean blockExternal) {
this.context = context;
this.tldParser = new TldParser(namespaceAware, validation,
blockExternal);
@@ -109,13 +103,12 @@ public class TldScanner {
*
* @return the map of URI to TldResourcePath
*/
- public Map<String, TldResourcePath> getUriTldResourcePathMap() {
+ public Map<String,TldResourcePath> getUriTldResourcePathMap() {
return uriTldResourcePathMap;
}
/**
- * Returns the map of TldResourcePath to parsed XML files built by this
- * scanner.
+ * Returns the map of TldResourcePath to parsed XML files built by this
scanner.
*
* @return the map of TldResourcePath to parsed XML files
*/
@@ -133,11 +126,10 @@ public class TldScanner {
}
/**
- * Set the class loader used by the digester to create objects as a result
- * of this scan. Normally this only needs to be set when using JspC.
+ * Set the class loader used by the digester to create objects as a result
of this scan. Normally this only needs to
+ * be set when using JspC.
*
- * @param classLoader Class loader to use when creating new objects while
- * parsing TLDs
+ * @param classLoader Class loader to use when creating new objects while
parsing TLDs
*/
public void setClassLoader(ClassLoader classLoader) {
tldParser.setClassLoader(classLoader);
@@ -151,7 +143,8 @@ public class TldScanner {
/**
* Scan for TLDs defined in <jsp-config>.
- * @throws IOException Error reading resources
+ *
+ * @throws IOException Error reading resources
* @throws SAXException XML parsing error
*/
protected void scanJspConfig() throws IOException, SAXException {
@@ -172,16 +165,12 @@ public class TldScanner {
resourcePath = WEB_INF + resourcePath;
}
if (uriTldResourcePathMap.containsKey(taglibURI)) {
- log.warn(Localizer.getMessage(MSG + ".webxmlSkip",
- resourcePath,
- taglibURI));
+ log.warn(Localizer.getMessage(MSG + ".webxmlSkip",
resourcePath, taglibURI));
continue;
}
if (log.isTraceEnabled()) {
- log.trace(Localizer.getMessage(MSG + ".webxmlAdd",
- resourcePath,
- taglibURI));
+ log.trace(Localizer.getMessage(MSG + ".webxmlAdd",
resourcePath, taglibURI));
}
URL url = context.getResource(resourcePath);
@@ -202,9 +191,7 @@ public class TldScanner {
listeners.addAll(tld.getListeners());
}
} else {
- log.warn(Localizer.getMessage(MSG +
".webxmlFailPathDoesNotExist",
- resourcePath,
- taglibURI));
+ log.warn(Localizer.getMessage(MSG +
".webxmlFailPathDoesNotExist", resourcePath, taglibURI));
continue;
}
}
@@ -214,11 +201,11 @@ public class TldScanner {
* Scan web application resources for TLDs, recursively.
*
* @param startPath the directory resource to scan
+ *
* @throws IOException if there was a problem scanning for or loading a
TLD
* @throws SAXException if there was a problem parsing a TLD
*/
- protected void scanResourcePaths(String startPath)
- throws IOException, SAXException {
+ protected void scanResourcePaths(String startPath) throws IOException,
SAXException {
boolean found = false;
Set<String> dirList = context.getResourcePaths(startPath);
@@ -266,8 +253,7 @@ public class TldScanner {
}
protected void parseTld(String resourcePath) throws IOException,
SAXException {
- TldResourcePath tldResourcePath =
- new TldResourcePath(context.getResource(resourcePath),
resourcePath);
+ TldResourcePath tldResourcePath = new
TldResourcePath(context.getResource(resourcePath), resourcePath);
parseTld(tldResourcePath);
}
@@ -301,16 +287,13 @@ public class TldScanner {
boolean found = false;
URL jarFileUrl = jar.getJarFileURL();
jar.nextEntry();
- for (String entryName = jar.getEntryName();
- entryName != null;
- jar.nextEntry(), entryName = jar.getEntryName()) {
- if (!(entryName.startsWith("META-INF/") &&
- entryName.endsWith(TLD_EXT))) {
+ for (String entryName = jar.getEntryName(); entryName != null;
jar.nextEntry(), entryName =
+ jar.getEntryName()) {
+ if (!(entryName.startsWith("META-INF/") &&
entryName.endsWith(TLD_EXT))) {
continue;
}
found = true;
- TldResourcePath tldResourcePath =
- new TldResourcePath(jarFileUrl, webappPath, entryName);
+ TldResourcePath tldResourcePath = new
TldResourcePath(jarFileUrl, webappPath, entryName);
try {
parseTld(tldResourcePath);
} catch (SAXException e) {
@@ -324,15 +307,13 @@ public class TldScanner {
} else {
foundJarWithoutTld = true;
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage(
- "jsp.tldCache.noTldInJar", jarFileUrl.toString()));
+ log.debug(Localizer.getMessage("jsp.tldCache.noTldInJar",
jarFileUrl.toString()));
}
}
}
@Override
- public void scan(File file, final String webappPath, boolean isWebapp)
- throws IOException {
+ public void scan(File file, final String webappPath, boolean isWebapp)
throws IOException {
File metaInf = new File(file, "META-INF");
if (!metaInf.isDirectory()) {
return;
@@ -341,12 +322,9 @@ public class TldScanner {
final Path filePath = file.toPath();
Files.walkFileTree(metaInf.toPath(), new SimpleFileVisitor<Path>()
{
@Override
- public FileVisitResult visitFile(Path file,
- BasicFileAttributes attrs)
- throws IOException {
+ public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
Path fileName = file.getFileName();
- if (fileName == null || !fileName.toString().toLowerCase(
- Locale.ENGLISH).endsWith(TLD_EXT)) {
+ if (fileName == null ||
!fileName.toString().toLowerCase(Locale.ENGLISH).endsWith(TLD_EXT)) {
return FileVisitResult.CONTINUE;
}
@@ -355,8 +333,7 @@ public class TldScanner {
if (webappPath == null) {
resourcePath = null;
} else {
- String subPath = file.subpath(
- filePath.getNameCount(),
file.getNameCount()).toString();
+ String subPath = file.subpath(filePath.getNameCount(),
file.getNameCount()).toString();
if ('/' != File.separatorChar) {
subPath = subPath.replace(File.separatorChar, '/');
}
@@ -375,13 +352,11 @@ public class TldScanner {
});
if (foundFileWithoutTld) {
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.tldCache.tldInDir",
- file.getAbsolutePath()));
+ log.debug(Localizer.getMessage("jsp.tldCache.tldInDir",
file.getAbsolutePath()));
}
} else {
if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir",
- file.getAbsolutePath()));
+ log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir",
file.getAbsolutePath()));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]