From 0d36b85fb627168a0c32df0608b8a3ea062d6b2e Mon Sep 17 00:00:00 2001 From: Paul Nicolucci Date: Mon, 27 Aug 2018 13:25:07 -0400 Subject: [PATCH 1/3] Issue #4809: Remove internal designation for servletPathForDefaultMapping --- .../resources/OSGI-INF/metatype/metatype.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/com.ibm.ws.webcontainer/resources/OSGI-INF/metatype/metatype.xml b/dev/com.ibm.ws.webcontainer/resources/OSGI-INF/metatype/metatype.xml index e70dbf2604d8..a106f381daa2 100644 --- a/dev/com.ibm.ws.webcontainer/resources/OSGI-INF/metatype/metatype.xml +++ b/dev/com.ibm.ws.webcontainer/resources/OSGI-INF/metatype/metatype.xml @@ -305,8 +305,8 @@ From 8db39852f208e8a21860535db9b059a5bf256a89 Mon Sep 17 00:00:00 2001 From: Paul Nicolucci Date: Thu, 30 Aug 2018 16:50:57 -0400 Subject: [PATCH 2/3] Issue #4809: Add Test Case for Servlet Path Default Servlet Mapping --- .../.classpath | 1 + .../bnd.bnd | 3 +- .../fat/src/com/ibm/ws/fat/wc/FATSuite.java | 27 ++--- ...WCServletPathForDefaultMappingDefault.java | 95 ++++++++++++++++ .../WCServletPathForDefaultMappingFalse.java | 102 ++++++++++++++++++ .../.gitignore | 2 + .../bootstrap.properties | 4 + .../server.xml | 15 +++ .../.gitignore | 2 + .../bootstrap.properties | 4 + .../server.xml | 16 +++ .../ServletPathDefaultMappingServlet.java | 40 +++++++ 12 files changed, 298 insertions(+), 13 deletions(-) create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingDefault.java create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingFalse.java create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/.gitignore create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/bootstrap.properties create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/server.xml create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/.gitignore create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/bootstrap.properties create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/server.xml create mode 100644 dev/com.ibm.ws.webcontainer.servlet.4.0_fat/test-applications/ServletPathDefaultMapping.war/src/servletpathdefaultmapping/war/servlets/ServletPathDefaultMappingServlet.java diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/.classpath b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/.classpath index 5a5f800a3400..ccbef414c204 100644 --- a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/.classpath +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/.classpath @@ -7,6 +7,7 @@ + diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/bnd.bnd b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/bnd.bnd index 1c738a9cd0eb..dc859ce5ac63 100644 --- a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/bnd.bnd +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/bnd.bnd @@ -18,7 +18,8 @@ src: \ test-applications/TestGetMapping.war/src,\ test-applications/TestAddJspFile.war/src, \ test-applications/TestEncoding.war/src, \ - test-applications/TestPushBuilderSecurity.war/src + test-applications/TestPushBuilderSecurity.war/src, \ + test-applications/ServletPathDefaultMapping.war/src fat.project: true diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/FATSuite.java b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/FATSuite.java index 1a55fa48a578..b64ad7883dba 100644 --- a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/FATSuite.java +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/FATSuite.java @@ -1,14 +1,13 @@ -/* - * IBM Confidential +/******************************************************************************* + * Copyright (c) 2012, 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * OCO Source Materials - * - * Copyright IBM Corp. 2012, 2014 - * - * The source code for this program is not published or otherwise divested - * of its trade secrets, irrespective of what has been deposited with the - * U.S. Copyright Office. - */ + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package com.ibm.ws.fat.wc; import org.junit.BeforeClass; @@ -25,6 +24,8 @@ import com.ibm.ws.fat.wc.tests.WCPushBuilderTest; import com.ibm.ws.fat.wc.tests.WCServerTest; import com.ibm.ws.fat.wc.tests.WCServletClarificationTest; +import com.ibm.ws.fat.wc.tests.WCServletPathForDefaultMappingDefault; +import com.ibm.ws.fat.wc.tests.WCServletPathForDefaultMappingFalse; import com.ibm.ws.fat.wc.tests.WCTrailersTest; /** @@ -45,7 +46,7 @@ * "fat.test.mode=full" to the properties tab, then launch the * build. * - * Alternatively, for a comand line launch, add "-Dfat.test.mode=full". + * Alternatively, for a command line launch, add "-Dfat.test.mode=full". */ @RunWith(Suite.class) @SuiteClasses({ @@ -58,7 +59,9 @@ WCEncodingTest.class, WCTrailersTest.class, // WCPushBuilderSecurityTest.class, - WCAddJspFileTest.class + WCAddJspFileTest.class, + WCServletPathForDefaultMappingDefault.class, + WCServletPathForDefaultMappingFalse.class }) public class FATSuite { diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingDefault.java b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingDefault.java new file mode 100644 index 000000000000..33dd50212b87 --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingDefault.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.ws.fat.wc.tests; + +import java.util.logging.Logger; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.ws.fat.util.LoggingTest; +import com.ibm.ws.fat.util.SharedServer; +import com.ibm.ws.fat.wc.WCApplicationHelper; + +import componenttest.custom.junit.runner.FATRunner; + +/** + * This is a test class for the servlet-4.0 feature to test the behavior when servletPathForDefaultMapping + * is true. There is no need to set the property in the server.xml because the value is true by default + * for the servlet-4.0 feature. + * + */ +@RunWith(FATRunner.class) +public class WCServletPathForDefaultMappingDefault extends LoggingTest { + + private static final Logger LOG = Logger.getLogger(WCServletPathForDefaultMappingDefault.class.getName()); + + @ClassRule + public static SharedServer SHARED_SERVER = new SharedServer("servlet40_ServletPathForDefaultMapping_Default"); + + @BeforeClass + public static void setUp() throws Exception { + + LOG.info("Setup : add ServletPathDefaultMapping.war to the server if not already present."); + + WCApplicationHelper.addWarToServerDropins(SHARED_SERVER.getLibertyServer(), "ServletPathDefaultMapping.war", false, + "servletpathdefaultmapping.war.servlets"); + + SHARED_SERVER.startIfNotStarted(); + + LOG.info("Setup : wait for message to indicate app has started"); + + SHARED_SERVER.getLibertyServer().waitForStringInLog("CWWKZ0001I.* ServletPathDefaultMapping", 10000); + + LOG.info("Setup : complete, ready for Tests"); + + } + + /** + * Test to ensure that the default behavior when using the servlet-4.0 feature is + * that a request to the default servlet will result in: + * + * servlet path = / + requestURI - context path + * path info = null + * + * @throws Exception + */ + @Test + public void testServletPathForDefaultMapping_Default() throws Exception { + this.verifyResponse("/ServletPathDefaultMapping", "ServletPath = / PathInfo = null"); + } + + /** + * Test to ensure that the default behavior when using the servlet-4.0 feature is + * that a request to the default servlet will result in: + * + * servlet path = / + requestURI - context path + * path info = null + * + * @throws Exception + */ + @Test + public void testServletPathForDefaultMapping_Default_2() throws Exception { + this.verifyResponse("/ServletPathDefaultMapping/index.html", "ServletPath = /index.html PathInfo = null"); + } + + /* + * (non-Javadoc) + * + * @see com.ibm.ws.fat.util.LoggingTest#getSharedServer() + */ + @Override + protected SharedServer getSharedServer() { + return SHARED_SERVER; + } +} diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingFalse.java b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingFalse.java new file mode 100644 index 000000000000..1918d54cc0ae --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/fat/src/com/ibm/ws/fat/wc/tests/WCServletPathForDefaultMappingFalse.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.ws.fat.wc.tests; + +import java.util.logging.Logger; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.ws.fat.util.LoggingTest; +import com.ibm.ws.fat.util.SharedServer; +import com.ibm.ws.fat.wc.WCApplicationHelper; + +import componenttest.custom.junit.runner.FATRunner; + +/** + * This is a test class for the servlet-4.0 feature to test the behavior when servletPathForDefaultMapping + * is false. Setting servletPathForDefaultMapping to false is the testing the non default behavior. + * + */ +@RunWith(FATRunner.class) +public class WCServletPathForDefaultMappingFalse extends LoggingTest { + + private static final Logger LOG = Logger.getLogger(WCServletPathForDefaultMappingFalse.class.getName()); + + @ClassRule + public static SharedServer SHARED_SERVER = new SharedServer("servlet40_ServletPathForDefaultMapping_False"); + + @BeforeClass + public static void setUp() throws Exception { + + LOG.info("Setup : add ServletPathDefaultMapping.war to the server if not already present."); + + WCApplicationHelper.addWarToServerDropins(SHARED_SERVER.getLibertyServer(), "ServletPathDefaultMapping.war", false, + "servletpathdefaultmapping.war.servlets"); + + SHARED_SERVER.startIfNotStarted(); + + LOG.info("Setup : wait for message to indicate app has started"); + + SHARED_SERVER.getLibertyServer().waitForStringInLog("CWWKZ0001I.* ServletPathDefaultMapping", 10000); + + LOG.info("Setup : complete, ready for Tests"); + + } + + /** + * Test to ensure that if we set servletPathForDefaultMapping to false in the server.xml ( not the + * default value for the servlet-4.0 feature) then a request to the default servlet will result in: + * + * servlet path = "" (empty string) + * path info = / request URI - context path + * + * This is the incorrect behavior + * according to the servlet specification and that is why we're making it the non default behavior + * for the servlet-4.0 feature. + * + * @throws Exception + */ + @Test + public void testServletPathForDefaultMapping_False() throws Exception { + this.verifyResponse("/ServletPathDefaultMapping", "ServletPath = PathInfo = /"); + } + + /** + * Test to ensure that if we set servletPathForDefaultMapping to false in the server.xml ( not the + * default value for the servlet-4.0 feature) then a request to the default servlet will result in: + * + * servlet path = "" (empty string) + * path info = / request URI - context path + * + * This is the incorrect behavior + * according to the servlet specification and that is why we're making it the non default behavior + * for the servlet-4.0 feature. + * + * @throws Exception + */ + @Test + public void testServletPathForDefaultMapping_False_2() throws Exception { + this.verifyResponse("/ServletPathDefaultMapping/index.html", "ServletPath = PathInfo = /index.html"); + } + + /* + * (non-Javadoc) + * + * @see com.ibm.ws.fat.util.LoggingTest#getSharedServer() + */ + @Override + protected SharedServer getSharedServer() { + return SHARED_SERVER; + } +} diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/.gitignore b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/.gitignore new file mode 100644 index 000000000000..47ebb767c4dc --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/.gitignore @@ -0,0 +1,2 @@ +/apps +/dropins diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/bootstrap.properties b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/bootstrap.properties new file mode 100644 index 000000000000..763a7a5b0ce3 --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/bootstrap.properties @@ -0,0 +1,4 @@ +bootstrap.include=../testports.properties +osgi.console=7777 +com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all +com.ibm.ws.classloading.tcclLockWaitTimeMillis=60000 diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/server.xml b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/server.xml new file mode 100644 index 000000000000..ae8ba7e257bb --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_Default/server.xml @@ -0,0 +1,15 @@ + + + + + + servlet-4.0 + + + + + \ No newline at end of file diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/.gitignore b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/.gitignore new file mode 100644 index 000000000000..47ebb767c4dc --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/.gitignore @@ -0,0 +1,2 @@ +/apps +/dropins diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/bootstrap.properties b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/bootstrap.properties new file mode 100644 index 000000000000..763a7a5b0ce3 --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/bootstrap.properties @@ -0,0 +1,4 @@ +bootstrap.include=../testports.properties +osgi.console=7777 +com.ibm.ws.logging.trace.specification=*=info:com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HttpTransport=all:HTTPChannel=all:TCPChannel=all:GenericBNF=all:com.ibm.ws.jsp*=all:com.ibm.ws.session.*=all:com.ibm.ws.runtime.update.internal*=all:ChannelFramework=all +com.ibm.ws.classloading.tcclLockWaitTimeMillis=60000 diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/server.xml b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/server.xml new file mode 100644 index 000000000000..fb62a5884308 --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/publish/servers/servlet40_ServletPathForDefaultMapping_False/server.xml @@ -0,0 +1,16 @@ + + + + + + servlet-4.0 + + + + + + \ No newline at end of file diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/test-applications/ServletPathDefaultMapping.war/src/servletpathdefaultmapping/war/servlets/ServletPathDefaultMappingServlet.java b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/test-applications/ServletPathDefaultMapping.war/src/servletpathdefaultmapping/war/servlets/ServletPathDefaultMappingServlet.java new file mode 100644 index 000000000000..c0114621ad96 --- /dev/null +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0_fat/test-applications/ServletPathDefaultMapping.war/src/servletpathdefaultmapping/war/servlets/ServletPathDefaultMappingServlet.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package servletpathdefaultmapping.war.servlets; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + */ +@WebServlet("/") +public class ServletPathDefaultMappingServlet extends HttpServlet { + + public ServletPathDefaultMappingServlet() { + + } + + @Override + protected void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { + ServletOutputStream sos = res.getOutputStream(); + + sos.println("RequestURI = " + req.getRequestURI()); + sos.println(); + sos.println("ServletPath = " + req.getServletPath() + " PathInfo = " + req.getPathInfo()); + } +} From 2da8544bc4a987edf5018473c313d9f328254ad9 Mon Sep 17 00:00:00 2001 From: Paul Nicolucci Date: Wed, 5 Sep 2018 20:39:59 -0400 Subject: [PATCH 3/3] Issue #4809: Updates for servletPathForDefaultMapping --- .../webcontainer40/util/URIMatcher40.java | 2 +- .../webcontainer/servlet/ServletConfig.java | 2 +- .../webcontainer/srt/SRTServletRequest.java | 6 ++++- .../webapp/WebAppDispatcherContext.java | 19 ++-------------- .../webcontainer/WCCustomProperties.java | 22 ++++++++++++++++++- .../wsspi/webcontainer/util/URIMatcher.java | 3 ++- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/dev/com.ibm.ws.webcontainer.servlet.4.0/src/com/ibm/wsspi/webcontainer40/util/URIMatcher40.java b/dev/com.ibm.ws.webcontainer.servlet.4.0/src/com/ibm/wsspi/webcontainer40/util/URIMatcher40.java index e256dffbdf09..130c7adc907f 100644 --- a/dev/com.ibm.ws.webcontainer.servlet.4.0/src/com/ibm/wsspi/webcontainer40/util/URIMatcher40.java +++ b/dev/com.ibm.ws.webcontainer.servlet.4.0/src/com/ibm/wsspi/webcontainer40/util/URIMatcher40.java @@ -217,7 +217,7 @@ public Object match(IExtendedRequest req) { // PK80340 Start Object starTarget = defaultNode.getStarTarget(); - if (WCCustomProperties.ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS && (starTarget instanceof ServletWrapper) && ((ServletWrapper) starTarget).isDefaultServlet()) { + if (URIMatcher.SERVLET_PATH_FOR_DEFAULT_MAPPING && (starTarget instanceof ServletWrapper) && ((ServletWrapper) starTarget).isDefaultServlet()) { dispatchContext.setPathElements(uri, null); } else { dispatchContext.setPathElements("", uri); diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/ServletConfig.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/ServletConfig.java index 77298a28fc04..e14b3208d580 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/ServletConfig.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/servlet/ServletConfig.java @@ -220,7 +220,7 @@ public void setMappings(List list) { public List getMappings() { // start PI23529 - if(mappings == null && (WCCustomProperties.EMPTY_SERVLET_MAPPINGS || com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() == WebContainer.SPEC_LEVEL_31 )){ + if(mappings == null && (WCCustomProperties.EMPTY_SERVLET_MAPPINGS || com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= WebContainer.SPEC_LEVEL_31 )){ return new ArrayList(); } //end PI23529 diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletRequest.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletRequest.java index cc8ad2aacf24..238e60d31f98 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletRequest.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/srt/SRTServletRequest.java @@ -202,6 +202,8 @@ public class SRTServletRequest implements HttpServletRequest, IExtendedRequest, private boolean usedStartAsyncNoParameters = false; //PI43752 end + protected static final boolean SERVLET_PATH_FOR_DEFAULT_MAPPING = Boolean.valueOf(WCCustomProperties.SERVLET_PATH_FOR_DEFAULT_MAPPING).booleanValue(); + public SRTServletRequest(SRTConnectionContext context) { this._connContext = context; @@ -2003,7 +2005,9 @@ public String getServletPath() { // 321485 String path = ((WebAppDispatcherContext) this.getDispatchContext()).getServletPath(); //PM59297 ...in case this servlet is a default servlet AND contains a ;jsessionid= which needs to be stripped off - if (WCCustomProperties.ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS || WCCustomProperties.REMOVE_TRAILING_SERVLET_PATH_SLASH) { + + //Starting 18.0.0.4, use SERVLET_PATH_FOR_DEFAULT_MAPPING instead. + if (SERVLET_PATH_FOR_DEFAULT_MAPPING || WCCustomProperties.REMOVE_TRAILING_SERVLET_PATH_SLASH) { if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) { //306998.15 logger.logp(Level.FINE, CLASS_NAME, "getServletPath", "stripping path -> " + path); } diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebAppDispatcherContext.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebAppDispatcherContext.java index 48118332321a..8181884859da 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebAppDispatcherContext.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebAppDispatcherContext.java @@ -81,21 +81,6 @@ public abstract class WebAppDispatcherContext implements Cloneable, IWebAppDispa private static final boolean removeServletPathSlash = WCCustomProperties.REMOVE_TRAILING_SERVLET_PATH_SLASH; private boolean possibleSlashStarMapping = true; //PK39337 - - //4666 - private static final String SET_SERVLET_PATH_FOR_DEFAULT_MAPPING = WCCustomProperties.SERVLET_PATH_FOR_DEFAULT_MAPPING; - private static boolean isServletPathForDefaultMapping = false; - static{ - if (SET_SERVLET_PATH_FOR_DEFAULT_MAPPING == null){ - if (WebContainer.getServletContainerSpecLevel() >= WebContainer.SPEC_LEVEL_40) - isServletPathForDefaultMapping = true; - } - else{ - isServletPathForDefaultMapping = Boolean.valueOf(SET_SERVLET_PATH_FOR_DEFAULT_MAPPING).booleanValue(); - } - logger.logp(Level.FINE, CLASS_NAME,"static", "set servlet path for default mapping " + isServletPathForDefaultMapping); - } - //4666 //other object not needing Cloning //======================== @@ -931,7 +916,7 @@ public void setPathElements(String servletPath, String pathInfo) logger.logp(Level.FINE, CLASS_NAME,"setPathElements", "servletPath = " + servletPath +", pathInfo = " + pathInfo +" : this = " + this); } //PK39337 - start - if (removeServletPathSlash || isServletPathForDefaultMapping) { //4666 preserve the old removeServletPathSlash in case of migration/upgrade. + if (removeServletPathSlash) { boolean hasSlashStar = false; boolean isPossible = isPossibleSlashStarMapping(); @@ -975,7 +960,7 @@ else if (isPossible) { } } //PK39337 - end - else if (servletPath.length()==1 && servletPath.charAt(0)=='/'){ + else if (servletPath.length()==1 && servletPath.charAt(0)=='/' && !Boolean.valueOf(WCCustomProperties.SERVLET_PATH_FOR_DEFAULT_MAPPING).booleanValue()) { this._servletPath = ""; if (pathInfo ==null) this._pathInfo = "/"; diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/WCCustomProperties.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/WCCustomProperties.java index da7ebabbdb65..ef5bdbd01e45 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/WCCustomProperties.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/WCCustomProperties.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1997, 2008 IBM Corporation and others. + * Copyright (c) 1997, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -94,7 +94,10 @@ public class WCCustomProperties { public static String SUPPRESS_HEADERS_IN_REQUEST; //PK80362 public static boolean DISPATCHER_RETHROW_SER; // PK79464 + + // 18.0.0.4 Do not use ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS. Use SERVLET_PATH_FOR_DEFAULT_MAPPING instead going forward public static boolean ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS; // PK80340 + public static boolean COPY_ATTRIBUTES_KEY_SET; //PK81452 public static boolean SUPPRESS_LAST_ZERO_BYTE_PACKAGE; // PK82794 public static boolean DEFAULT_TRACE_REQUEST_BEHAVIOR; // PK83258.2 @@ -475,6 +478,8 @@ public static void setCustomProperties(Map d) { setCustomPropertyVariables(); //Need to update all the variables. + setCustomizedDefaultValues(); //Customize default value depending on servlet level, initial size....etc.. + if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "setCustomProperties"); } @@ -780,4 +785,19 @@ public static void setCustomPropertyVariables() { } + private static void setCustomizedDefaultValues(){ + Tr.debug(tc, "Customized default values: "); + + //18.0.0.4 SERVLET_PATH_FOR_DEFAULT_MAPPING has highest priority. If not present AND ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS is true, set SERVLET_PATH_FOR_DEFAULT_MAPPING + if (SERVLET_PATH_FOR_DEFAULT_MAPPING == null || SERVLET_PATH_FOR_DEFAULT_MAPPING.isEmpty()){ + if (ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS) + SERVLET_PATH_FOR_DEFAULT_MAPPING = "true"; + else + SERVLET_PATH_FOR_DEFAULT_MAPPING = ((com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= com.ibm.ws.webcontainer.osgi.WebContainer.SPEC_LEVEL_40) ? "true" : "false" ); + + Tr.debug(tc, "servletpathfordefaultmapping = " + SERVLET_PATH_FOR_DEFAULT_MAPPING); + } + +} + } diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/URIMatcher.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/URIMatcher.java index 41afd9d10d7b..14d2669a2871 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/URIMatcher.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/URIMatcher.java @@ -24,6 +24,7 @@ public class URIMatcher extends com.ibm.ws.webcontainer.util.URIMatcher { private static Logger logger = LoggerFactory.getInstance().getLogger("com.ibm.wsspi.webcontainer.util"); private static final String CLASS_NAME = "com.ibm.wsspi.webcontainer.util.URIMatcher"; + protected static final boolean SERVLET_PATH_FOR_DEFAULT_MAPPING = Boolean.valueOf(WCCustomProperties.SERVLET_PATH_FOR_DEFAULT_MAPPING).booleanValue(); public URIMatcher() { super(); @@ -184,7 +185,7 @@ public Object match(IExtendedRequest req) { // PK80340 Start Object starTarget = defaultNode.getStarTarget(); - if (WCCustomProperties.ENABLE_DEFAULT_SERVLET_REQUEST_PATH_ELEMENTS && (starTarget instanceof ServletWrapper) && ((ServletWrapper) starTarget).isDefaultServlet()) { + if (SERVLET_PATH_FOR_DEFAULT_MAPPING && (starTarget instanceof ServletWrapper) && ((ServletWrapper) starTarget).isDefaultServlet()) { dispatchContext.setPathElements(uri, null); } else { dispatchContext.setPathElements("", uri);