001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.web.config; 018 019import org.eclipse.jetty.server.Handler; 020import org.eclipse.jetty.server.Server; 021import org.eclipse.jetty.server.handler.HandlerCollection; 022import org.eclipse.jetty.webapp.Configuration; 023import org.eclipse.jetty.webapp.WebAppContext; 024 025/** 026 * 027 * 028 */ 029public class JspConfigurer { 030 031 public static void configureJetty(Server server, HandlerCollection collection) { 032 Configuration.ClassList classlist = Configuration.ClassList 033 .setServerDefault( server ); 034 classlist.addBefore( 035 "org.eclipse.jetty.webapp.JettyWebXmlConfiguration", 036 "org.eclipse.jetty.annotations.AnnotationConfiguration" ); 037 038 // Set the ContainerIncludeJarPattern so that jetty examines these 039 // container-path jars for tlds, web-fragments etc. 040 // If you omit the jar that contains the jstl .tlds, the jsp engine will 041 // scan for them instead. 042 for (Handler handler: collection.getHandlers()) { 043 if (handler instanceof WebAppContext){ 044 ((WebAppContext) handler).setAttribute( 045 "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", 046 ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" ); 047 } 048 } 049 } 050}