From users-return-265599-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Sat Sep 22 18:52:24 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 55DF118065B for ; Sat, 22 Sep 2018 18:52:24 +0200 (CEST) Received: (qmail 28172 invoked by uid 500); 22 Sep 2018 16:52:22 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 28161 invoked by uid 99); 22 Sep 2018 16:52:22 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Sep 2018 16:52:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1A1A1C0158 for ; Sat, 22 Sep 2018 16:52:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.989 X-Spam-Level: * X-Spam-Status: No, score=1.989 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=lucee-org.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 59YMsNBuT2g9 for ; Sat, 22 Sep 2018 16:52:20 +0000 (UTC) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id D231E5F536 for ; Sat, 22 Sep 2018 16:52:19 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id l19-v6so266806ljb.0 for ; Sat, 22 Sep 2018 09:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lucee-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=iCxvtwJq8ES9ld1hmKkpGbIYm4y9RxC4F0iYlqVaM5I=; b=Ht2b2Kt86hPcRaOxnc/VqKCxlxxrhEc+cpEfE01XSQbtrSOR2jxe17p2sW7q2CzgWS C/fBgKnwuUDs0IAuKAQUwZ19085M7vzcL4e7Uz3mknBbheVdfsB44C6XIwPVhdyyMBO3 /b4Hz1XmHWO4FwBgIDYaOyVbbsuxLRPM9fsxzLten9gPX1JhbLLdgrzx/WK7YPwskhRL NQk9k0ZKu3DJuJFjlasVjUKnhkLtPaGM0OVBoYZmZHqCyJ7jwar9eG+IXwXPPPESlzyp P1+ZOmTTGNTqnJ+QCpPkKy4yK3QC4bH9tysshlEJzGr1vfIwweqlp+mLLND6Pvo6/Vg9 1MAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iCxvtwJq8ES9ld1hmKkpGbIYm4y9RxC4F0iYlqVaM5I=; b=ZMnzhalcJ1vOhNcX+e8stQUvo4FOtQgQvAdb8PFPVoAgBBiVOWX4I95P6izjjeyJt4 eWirpUTP/4ZFE4B+KMZg0r9xm7nQf4sXAaAtfufW28y6P5UErQnz241uKeMe89CdHr+p d11xlClRHskb3cg+r7QV5M3e1661E48o42ckBGt+5+IdGvbeQ0ux18lGU3XqfVjI/gsV sR18xXStyIyuASIr0j2vWcCLUXlfj9/5LW8Xx+P1DnEBfDT5b5X7r9la75IaVveUyE31 WHR5jrZeJo3HMHwaDQVsLV27FAVpxO6Ou0xoMT6r8YnfukDZO7YIpSdiKnfwOJTe7Nt6 qnWg== X-Gm-Message-State: APzg51AlSx8O++t0f18KF/a2P955Sgruh7CpCMeWX3ihDNu7XbTIPibW 9/ptbhXth6pMiWFl/0wjgWYvqaHKVl7Ivn0E88x9bEcAzto= X-Google-Smtp-Source: ANB0VdYHn0J6BlQqqIdaDBt8ODhrMj2PuhKHnRxJeRhHHSeOLlbfiNUKzF7P+Jdg8aVsL+mEQCt6zKCM/kqQGL+c09U= X-Received: by 2002:a2e:8:: with SMTP id 8-v6mr5751010lja.112.1537635139124; Sat, 22 Sep 2018 09:52:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Igal Sapir Date: Sat, 22 Sep 2018 09:52:07 -0700 Message-ID: Subject: Re: How to Disable JSP in Embedded Tomcat To: Tomcat-Users Content-Type: multipart/alternative; boundary="000000000000430e3f057678942c" --000000000000430e3f057678942c Content-Type: text/plain; charset="UTF-8" On Sat, Sep 22, 2018 at 2:10 AM Mark Thomas wrote: > > On 22/09/2018 01:11, Igal Sapir wrote: > > Mark, > > > > On Fri, Sep 21, 2018 at 12:54 AM Mark Thomas wrote: > > > >> On 21/09/18 05:57, Igal Sapir wrote: > >>> I want to embed Tomcat in a simple application that does not use JSP, > and > >>> that sets the default servlet's listings initParam to true. > >>> > >>> When I use the StandardContext, Tomcat.initWebappDefaults() [1] is > called > >>> and adds the default servlet and the JSP servlet. I would like to > >> prevent > >>> that, but hopefully without having to rewrite the whole Tomcat class > nor > >> to > >>> subclass it. > >>> > >>> Further, when I try to override a setting in WEB-INF/web.xml, e.g. to > >>> specify init-param of "listings" with value "true" for the servlet > >>> "default", I get an error that "default" is not unique, but in a > regular > >>> Tomcat deployment that works just fine. > >>> > >>> Is there an easy way to override Tomcat.initWebappDefaults() or to > >> prevent > >>> it from being called? > >> > >> There are a couple few options. > >> > >> Sub-classing looks to be the simplest. > >> > >> You can use addContext() rather than addWebapp() but then you become > >> responsible for all of the configuration. If the app is simple, this > >> shouldn't be too much effort. > >> > > > > The app is simple, but it is for use by other developers who may use > their > > own web.xml files, so I think that sub-classing would be much easier and > > that's what I did. > > > > While searching for a solution prior to asking on the mailing list, I > > noticed that quite a few users were looking for a simple solution of > using > > addWebapp() without setting up the default servlets. What do you think > > about adding a System Property that will allow to opt-out of > > initWebappDefaults() and set the DefaultWebXml to null so that the > web.xml > > files will be parsed? > > I have a huge dislike for using system properties for configuration. A > setter on the Tomcat class would be fine. > Even better. I'll add that. https://bz.apache.org/bugzilla/show_bug.cgi?id=62755 > > > I am thinking of a property name > > org.apache.catalina.startup.INIT_WEBAPP_DEFAULTS [default true], or > > org.apache.catalina.startup.DISABLE_WEBAPP_DEFAULTS [default false]. > > > > Alternatively, we can add the sub-classing implementation that I used > (with > > the proper ASF license headers, of course). The code is pasted below in > > case anyone else needs such an implementation. > > > > I can add either solution myself if approved. > > I can imagine different users wanting to do various different things > here. I am wondering if there is a better way of handling this. The > tricky part is that we want to offer lots of flexibility in what is a > potentially complex area while keeping usage really simple. > True, but currently the reasonable defaults are always added and there is no simple way to undo them, so allowing the user to opt-out of the defaults will let him/her start from scratch and add only the required configurations. Igal --000000000000430e3f057678942c--