}
private void convertJsps(WebXml webXml) {
+ Map<String,String> jspInitParams;
ServletDef jspServlet = webXml.getServlets().get("jsp");
+ if (jspServlet == null) {
+ jspInitParams = new HashMap<String,String>();
+ Wrapper w = (Wrapper) context.findChild("jsp");
+ if (w != null) {
+ String[] params = w.findInitParameters();
+ for (String param : params) {
+ jspInitParams.put(param, w.findInitParameter(param));
+ }
+ }
+ } else {
+ jspInitParams = jspServlet.getParameterMap();
+ }
for (ServletDef servletDef: webXml.getServlets().values()) {
if (servletDef.getJspFile() != null) {
- convertJsp(servletDef, jspServlet);
+ convertJsp(servletDef, jspInitParams);
}
}
}
- private void convertJsp(ServletDef servletDef, ServletDef jspServletDef) {
+ private void convertJsp(ServletDef servletDef,
+ Map<String,String> jspInitParams) {
servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
String jspFile = servletDef.getJspFile();
if ((jspFile != null) && !jspFile.startsWith("/")) {
}
servletDef.getParameterMap().put("jspFile", jspFile);
servletDef.setJspFile(null);
- for (Map.Entry<String, String> initParam: jspServletDef.getParameterMap().entrySet()) {
+ for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
}
}
assertEquals("OK - Custom default Servlet", res.toString());
}
+ public void testBug51396() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp-3.0-fragments");
+ // app dir is relative to server home
+ tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+ tomcat.start();
+
+ ByteChunk bc = new ByteChunk();
+ int rc = getUrl("http://localhost:" + getPort() +
+ "/test/bug51396.jsp", bc, null);
+
+ assertEquals(HttpServletResponse.SC_OK, rc);
+ assertTrue(bc.toString().contains("<p>OK</p>"));
+ }
+
private static class CustomDefaultServletSCI
implements ServletContainerInitializer {
</web-resource-collection>
</security-constraint>
+ <!-- Bug 51396 -->
+ <servlet>
+ <servlet-name>bug51396</servlet-name>
+ <jsp-file>/bug51396.jsp</jsp-file>
+ </servlet>
+
</web-app>
\ No newline at end of file
--- /dev/null
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<html>
+ <body>
+ <p>OK</p>
+ </body>
+</html>
\ No newline at end of file
includes a SAXParserFactory is the first web application to be loaded.
(markt)
</fix>
+ <fix>
+ <bug>51396</bug>: Correctly handle jsp-file entries in web.xml when the
+ JSP servlet has been configured via code when embedding Tomcat. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">